jquery实现点击弹出对话框

1.html里面隐藏好一个div

<div> <div> <img alt="点击可以关闭" src="https://www.jb51.net/static/images/disk.png"> 删除时提示 </div> <div> <img alt="" src="https://www.jb51.net/delete.gif"> <span>你真的要删除所有分区吗?</span> </div> <div> <input type="button" value="确定"> <input type="button" value="取消"> </div> </div>

2.css样式里面增加一个弹出对话框的样式

.dialog{width:360px;border:1px #666 solid;position:absolute;display:none;z-index:101;} .dialog .title {background: #333;padding:10px; color: #fff; font-weight: bold; } .dialog .title img {float: right;} .dialog .content {background: #fff;padding:25px;height: 60px;} .dialog .content img {float: left;} .dialog .content span {float: left;padding:10px;} .dialog .bottom {text-align: right;padding:10px 10px 10px 0px;background: #eee;} .dialog .btn {border: #666 1px solid;width:65px;}

3.js里面监控点击弹框和弹框后的确定和取消动作

$(".delallpart").on("click",function () { $.ajax({ url:"/osd/opt/delallpart", type: "POST", datatype:'json', data: {"action":"del_all","del_mount":"2"}, beforeSend: function (xhr, settings) { xhr.setRequestHeader("X-CSRFToken", getCookie2('csrftoken')); }, success: function (arg) { var div = $("#delallpartdialog"); div.css("display", "block"); div.css("left", 500).css("top", 500); } }); }); $(".dialog").on("click",".btnnoOk", function () { alert("not ok"); $(this).parents(".dialog").css("display", "none"); }); $("#delallpartdialog").on("click",".btnok", function () { alert("ok!"); });

4.效果图

jquery实现点击弹出对话框

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/7c9ab7be436ae5e345a17d405f1eff7a.html