gpt4 book ai didi

暂停脚本执行的 jQuery 确认框

转载 作者:行者123 更新时间:2023-12-03 22:35:46 36 4
gpt4 key购买 nike

我正在寻找一个jquery/漂亮的标准对话框替代品。 jQUery UI 有一个很好的功能,但它不会像confirm() 那样暂停脚本执行以等待响应。下面的演示应该显示两个 div,显示前面确认框的选择,但 jquery 对话框不会导致脚本等待。

http://jsfiddle.net/EvilAmarant7x/r7Ur5/

我特别需要一些导致脚本暂停的东西。

谢谢

最佳答案

您以错误的方式使用对话框

你应该这样做

 $("#dialog-confirm").dialog({
resizable: false,
height: 140,
modal: true,
buttons: {
Proceed: function() {
call_true_function();
$(this).dialog("close");
},
Cancel: function() {
call_false_function()
$(this).dialog("close");
}
}
});

或者类似的东西

** 编辑 **

所以是这样的?

count = 0;
$("#dialog-confirm").dialog({
resizable: false,
height: 140,
modal: true,
buttons: {
Proceed: function() {
proceed();
$(this).dialog("close");
},
Cancel: function() {
$(this).dialog("close");
}
}
});

function proceed(){
if (count < 10){
count++;
$("#dialog-confirm").dialog('open');
}else{
$('body').append("<div>Yes was selected " + count + " times!</div>");
}
}

关于暂停脚本执行的 jQuery 确认框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5383271/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com