我正在设计一个网页.当我们点击div命名邮件的内容时,如何显示包含标签电子邮件和文本框的弹出窗口?
我希望使用jQuery的是/否警报,而不是ok/Cancel按钮:
jQuery.alerts.okButton = 'Yes';
jQuery.alerts.cancelButton = 'No';
jConfirm('Are you sure??', '', function(r) {
if (r == true) {
//Ok button pressed...
}
}
Run Code Online (Sandbox Code Playgroud)
还有其他选择吗?
function ValidateField(){
var bAllow= true;
//some checking here
if (bAllow == true && apl.val().trim() == "")
{
showDialog();
showDialog().done(function() {
return true; // wanna return true, but not success
}).fail(function() {
return false; //wanna return false, but not success
});
return false; //stop it to execute to next line
}
return bAllow; //success return }
function showDialog(){
var def = $.Deferred();
var modPop = '<div id="diaCom" title="Information?"><p>something something</p></div>';
$("#diaCom").remove();
$(modPop).appendTo('body');
$("#diaCom").dialog({
resizable: false,
draggable: false,
height:150,
width:300,
modal: true,
buttons: …Run Code Online (Sandbox Code Playgroud) 我试过这个: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>
Run Code Online (Sandbox Code Playgroud)
截屏:
jquery ×4
javascript ×2
jquery-ui ×2
ajax ×1
alerts ×1
confirm ×1
confirmation ×1
css ×1
jconfirm ×1
popup ×1