|
|
曾深爱过的蛋挞 · 坎贝尔:阿森纳必须不惜一切代价赢得冠军 ...· 1 月前 · |
|
|
坏坏的葡萄酒 · 济宁市审计局 图片新闻 ...· 1 年前 · |
|
|
鬼畜的冲锋衣 · 偷拍国企领导并举报可能会被判刑 - 知乎· 2 年前 · |
|
|
愤怒的警车 · 豪华SUV大爆发:蔚来ES7/宝马X5/理想 ...· 2 年前 · |
|
|
文雅的四季豆 · 银砂之翼漫画|官方在线漫画全集-快看· 2 年前 · |
我希望使用jQuery发出是/否警报,而不是使用确定/取消按钮:
jQuery.alerts.okButton = 'Yes';
jQuery.alerts.cancelButton = 'No';
jConfirm('Are you sure??', '', function(r) {
if (r == true) {
//Ok button pressed...
}
还有别的选择吗?
发布于 2012-05-25 19:29:08
ConfirmDialog('Are you sure');
function ConfirmDialog(message) {
$('<div></div>').appendTo('body')
.html('<div><h6>' + message + '?</h6></div>')
.dialog({
modal: true,
title: 'Delete message',
zIndex: 10000,
autoOpen: true,
width: 'auto',
resizable: false,
buttons: {
Yes: function() {
// $(obj).removeAttr('onclick');
// $(obj).parents('.Parent').remove();
$('body').append('<h1>Confirm Dialog Result: <i>Yes</i></h1>');
$(this).dialog("close");
No: function() {
$('body').append('<h1>Confirm Dialog Result: <i>No</i></h1>');
$(this).dialog("close");
close: function(event, ui) {
$(this).remove();
};
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
发布于 2013-08-27 02:49:10
alert方法会阻止执行,直到用户将其关闭:
使用确认功能:
if (confirm('Some message')) {
alert('Thanks for confirming');
} else {
alert('Why did you press cancel? You should have confirmed');
}
发布于 2014-07-21 16:29:49
我使用了以下代码:
HTML:
<a id="delete-button">Delete</a>
jQuery:
<script>
$("#delete-button").click(function(){
if(confirm("Are you sure you want to delete this?")){
$("#delete-button").attr("href", "query.php?ACTION=delete&ID='1'");