gpt4 book ai didi

javascript - 使用 jQuery UI 模态对话框作为确认

转载 作者:行者123 更新时间:2023-11-30 10:31:27 28 4
gpt4 key购买 nike

有没有一种方法可以使用基于 jQuery UI 的模式对话框而不是普通的 JS confirm() 进行确认?我希望能够做类似的事情:

if (jquery_ui_confirm('Are you sure?')) {
// do something
}

提前致谢。

最佳答案

var jqConfirm = function(msg, success) {
var dialogObj = $("<div style='display:none'>"+msg+"</div>");
$("body").append(dialogObj);
$(dialogObj).dialog({
resizable: false,
height:140,
modal: true,
buttons: {
"OK": function() {
success();
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
};

调用这个函数使用

jqConfirm("This will delete all records", function(){ /*do something here */});

关于javascript - 使用 jQuery UI 模态对话框作为确认,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16732830/

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