我只能找到confirm()
提供确定/取消按钮的功能。有没有办法给出是/否按钮?
Niyaz
问问题
16418 次
7 回答
8
于 2008-08-21T03:31:16.097 回答
2
不。
相反,您可以使用浏览器模式弹出窗口。
于 2008-08-21T03:25:45.470 回答
1
我是这类事情的jQuery UI Dialog的粉丝。这是一个样本...
<script>
$(function() {
$( "#dialog-confirm" ).dialog({
resizable: false,
height:140,
modal: true,
buttons: {
"Yes": function() {
$( this ).dialog( "close" );
alert("You chose Yes!");
},
"No": function() {
$( this ).dialog( "close" );
alert("You chose No!");
}
}
});
});
</script>
<div id="dialog-confirm" title="Are you sure you want to continue?">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>These items will be permanently deleted and cannot be recovered. Are you sure?</p>
</div>
于 2014-04-07T14:13:10.417 回答
1
我会使用 sweetalert https://sweetalert.js.org/guides/来实现这样的事情
swal("Are you sure you want to do this?", {
buttons: ["yes", "no"],
});
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
于 2018-01-07T21:07:49.507 回答
0
使用对话框显示是或否
<div id="dialog_box" class="mnk-modal-bg" style="display:none">
<div id="dbg" class="mnk-modal-box">
<i class="uk-icon-exclamation-triangle" style="color:#757575; padding-right:5px;">
</i>Confirm?
<div class="uk-text-center" style="margin-top:10px;">
<button class="md-btn md-btn-small md-btn-primary" id="ok_btn">
<i class="uk-icon-save" style="padding-right:3px;"></i>OK
</button>
<button class="md-btn md-btn-small md-btn-danger" id="close_btn">
<i class="uk-icon-remove" style="padding-right:3px;"></i>Cancel
</button>
</div>
</div>
<script>
$("#ok_btn").click(function(){
alert("OK");
$("#dialog_box").hide();
});
$("#close_btn").click(function(){
alert("CANCEL");
$("#dialog_box").hide();
});
</script>
于 2016-07-04T12:16:11.667 回答