我想在onclick
时询问确认消息这是我的代码:
$('#activate').click(function() {
var url='<?php echo getStoreURL($_REQUEST['key']); ?>admin/email_tracker.php';
var key='<?php echo $data['api_key'];?>'
$.post(url, { key:key, activate:1 } );
alert('Store activated');
location.reload(true);
});
我需要一个警告框你确定要激活吗?怎么做?。感谢
答案 0 :(得分:2)
试试这个,
$('#activate').click(function() {
var url='<?php echo getStoreURL($_REQUEST['key']); ?>admin/email_tracker.php';
var key='<?php echo $data['api_key'];?>'
if(!confirm("Your message")){ return; }
$.post(url, { key:key, activate:1 } );
alert('Store activated');
location.reload(true);
});
<强> PROCEDURAL DEMO 强>
答案 1 :(得分:0)
试试这个:
$('#activate').click(function() {
var Confirm = confirm("Are you sure?");
if (Confirm == true) {
//put your function here
}
});