【发布时间】:2016-06-16 12:25:28
【问题描述】:
我试过这个:https://stackoverflow.com/a/12617274/4164311。字符串“Are you sure about this”只是出现在我的浏览器中,当我单击按钮时没有任何反应。
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Dialog - Modal confirmation</title>
<link rel="stylesheet" href="jquery-ui.min.css">
<script src="external/jquery/jquery.js"></script>
<script src="jquery-ui.min.js"></script>
<script>
$("#dialog").dialog({
autoOpen: false,
modal: true,
buttons : {
"Confirm" : function() {
alert("You have confirmed!");
},
"Cancel" : function() {
$(this).dialog("close");
}
}
});
$("#callConfirm").on("click", function(e) {
e.preventDefault();
$("#dialog").dialog("open");
});
</script>
</head>
<body>
<button id="callConfirm">Confirm!</button>
<div id="dialog" title="Confirmation Required">
Are you sure about this?
</div>
</body>
</html>
截图:
【问题讨论】:
-
你真的要使用Jquery的对话吗? javascript基本的确认框还不够吗?
-
@kyori:是的。我无法使用确认框,因为浏览器会阻止打开其他对话框(例如 Chrome)。
标签: jquery jquery-ui confirm confirmation