我正在尝试使用一个JQUERY确认对话框,要求用户按下ok或cancel。它工作得很好,直到我把一个页面放在一个母版页里面。确认警报会显示一毫秒,然后消失。
window.onload = function() {
$("#ehi").click(function() {
$.confirm({
title: 'Are you sure you want to approve this application? Note: This action cannot be reverted. An automatic email will be sent to the student to notify him/her of the decision.',
content: '',
buttons: {
confirm: function() {
$.confirm({
title: 'Confirmed confirmation!',
content: 'Simple confirmation!',
buttons: {
confirm: function() {
},
cancel: function() {
},
}
});
},
cancel: function() {
},
somethingElse: {
text: 'Something else',
btnClass: 'btn-blue',
keys: ['enter', 'shift'],
action: function() {
$.alert('Something else?');
}
}
}
});
});
}<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.3/jquery-confirm.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.3/jquery-confirm.min.js"></script>
<button id="ehi" class="btn btn-info">confirm</button>
请注意,这在常规的page表单或页面中工作得很好。所以所有导入的链接都是好的。但是,每当我将页面放入母版页中时,它并不是这样的。
发布于 2017-07-31 17:31:23
在包含jquery.min.js之后,您需要包含jquery-confirm.min.js文件。所有这些脚本都应该在执行代码之前加载。
window.onload = function() {
$("#ehi").click(function() {
$.confirm({
title: 'Are you sure you want to approve this application? Note: This action cannot be reverted. An automatic email will be sent to the student to notify him/her of the decision.',
content: '',
buttons: {
confirm: function() {
$.confirm({
title: 'Confirmed confirmation!',
content: 'Simple confirmation!',
buttons: {
confirm: function() {
},
cancel: function() {
},
}
});
},
cancel: function() {
},
somethingElse: {
text: 'Something else',
btnClass: 'btn-blue',
keys: ['enter', 'shift'],
action: function() {
$.alert('Something else?');
}
}
}
});
});
}<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.3/jquery-confirm.min.js"></script>
<button id="ehi" class="btn btn-info">confirm</button>
发布于 2017-07-31 17:39:38
<button id="ehi" type="button" class="btn btn-info">confirm</button>或
$("#ContentPlaceHolder1_ehi").click();试试这个方法。
https://stackoverflow.com/questions/45412025
复制相似问题