jQuery支持多次确认的点击弹出确认对话框

2025-10-02 20:36:28

1、新建html文档。

jQuery支持多次确认的点击弹出确认对话框

2、书写hmtl代码。

<ul id="main">

<li id="onlyChoseAlert"><a href="#">单次单选弹框</a></li>

<li id="dblChoseAlert"><a href="#">单次双选弹框</a></li>

<li id="manyChoseAlert"><a href="#">多次双选弹框</a></li>

<li id="manyAllChoseAlert"><a href="#">多次双选弹框全关闭</a></li>

</ul>

jQuery支持多次确认的点击弹出确认对话框

3、书写css代码。

<style>

*{margin: 0;padding: 0;}

body{ background-color: #3A3A3A; }

#main{position: absolute;width: 200px;left: 50%;margin-left: -100px;top:200px;text-align: center;}

#main li{list-style-type: none;margin-top: 5px;}

#main li a{color: #fff;}

#main li a:hover{color: #99e;}

#main li a:active{color: #e99;}

</style>

jQuery支持多次确认的点击弹出确认对话框

4、书写并添加js代码。

<script src="js/jquery.min.js"></script>

<script src="js/simpleAlert.js"></script>

<script>

$(function () {

$("#onlyChoseAlert").click(function () {

var onlyChoseAlert = simpleAlert({

"content":"按确定消失按确定消失!",

"buttons":{

"确定":function () {

onlyChoseAlert.close();

}

}

})

})

$("#dblChoseAlert").click(function () {

var dblChoseAlert = simpleAlert({

"content":"按确定/取消消失!",

"buttons":{

"确定":function () {

alert("你好");

dblChoseAlert.close();

},

"取消":function () {

dblChoseAlert.close();

}

}

})

})

//多次双选弹框

$("#manyChoseAlert").click(function () {

var manyChoseAlert = simpleAlert({

"content":"按确定键按确定键按确定键按确定键按确定键按确定键按确定键按确定键按确定键按确定键按确定键按确定键按确定键!",

"buttons":{

"确定":function () {

var manyChoseAlert2 = simpleAlert({

"content":"再次确定!",

"buttons":{

"确定":function () {

var manyChoseAlert3 = simpleAlert({

"content":"最后确定!",

"buttons":{

"确定":function () {

manyChoseAlert3.close();

}

}

})

},

"取消":function () {

manyChoseAlert2.close();

}

}

})

},

"取消":function () {

manyChoseAlert.close();

}

}

})

})

//多次双选弹框全关闭

$("#manyAllChoseAlert").click(function () {

var manyAllChoseAlert = simpleAlert({

"content":"按确定键!",

"buttons":{

"确定":function () {

var manyAllChoseAlert2 = simpleAlert({

"content":"再次确定!",

"buttons":{

"确定":function () {

var manyAllChoseAlert3 = simpleAlert({

"content":"最后确定-全关闭!",

"closeAll":true,

"buttons":{

"确定":function () {

manyAllChoseAlert3.close();

}

}

})

},

"取消":function () {

manyAllChoseAlert2.close();

}

}

})

},

"取消":function () {

manyAllChoseAlert.close();

}

}

})

})

})

</script>

jQuery支持多次确认的点击弹出确认对话框

5、代码整体结构。

jQuery支持多次确认的点击弹出确认对话框

6、查看效果。

jQuery支持多次确认的点击弹出确认对话框

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢