我尝试了这个:https://dev59.com/L2cs5IYBdhLWcg3wu2cp#12617274。在我的浏览器中只出现了字符串“您确定吗”,当我点击按钮时没有任何反应。
截图:
<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>
截图:
![enter image description here](https://istack.dev59.com/9y3m4.webp)