![]() |
暴走的小熊猫 · 国际关系学院-对外经济贸易大学· 9 月前 · |
![]() |
满身肌肉的铁链 · 日产玛驰刹车灯是几颗?_太平洋汽车· 1 年前 · |
![]() |
重感情的茶壶 · 《我破碎的真理子》高清下载-电影-夕阳小站· 1 年前 · |
![]() |
坏坏的铁板烧 · -Auto Thinker汽车智库平台· 1 年前 · |
![]() |
胆小的风衣 · 特斯拉Model ...· 1 年前 · |
我希望使用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'");
![]() |
暴走的小熊猫 · 国际关系学院-对外经济贸易大学 9 月前 |
![]() |
满身肌肉的铁链 · 日产玛驰刹车灯是几颗?_太平洋汽车 1 年前 |
![]() |
重感情的茶壶 · 《我破碎的真理子》高清下载-电影-夕阳小站 1 年前 |
![]() |
坏坏的铁板烧 · -Auto Thinker汽车智库平台 1 年前 |