rzb*_*rzb 4 html php jquery jquery-ui jquery-ui-dialog
我有一个填充了数据库中数据的表,其中每一行都有一个单元格,里面有一个锚元素.这个锚将导致相同的页面,但有一个查询字符串告诉php哪一行包含它应该删除的数据.
我需要在用户点击锚点时打开一个jQuery对话框,要求他在加载URL之前确认他的意图."取消"按钮应关闭对话框,不执行任何操作.然后,"确定"按钮应该打开网址.
任何帮助都非常感谢.
//使用'我尝试过的'进行编辑.这是我第一次搞乱jQuery,学习的时间已经不多了... =(
jQuery(document).ready(function(){
var $dialog = jQuery('<div class='msg_dialog'></div>')
.html('Are you sure you want to do this?')
.dialog({
autoOpen: false,
title: 'Confirm action',
buttons: [{
text: "Cancel",
click: function(){
jQuery(this).dialog("close");
}
}] // didn't even try the OK button since I couldn't even get the dialog opened
});
jQuery('#confirm_del').click(function(){
$dialog.dialog('open');
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
And*_*ker 25
$("a").on("click", function(e) {
var link = this;
e.preventDefault();
$("<div>Are you sure you want to continue?</div>").dialog({
buttons: {
"Ok": function() {
window.location = link.href;
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
});
Run Code Online (Sandbox Code Playgroud)
示例: http ://jsfiddle.net/uRGJD/
(重定向到Google将无法在JSFiddle上运行,但应该在正常页面上运行)
如何使用:
<a href="<?php echo 'your_url'.'?query_string='.$query_string ?>" onclick="return confirm('Are your sure?')">
Go
</a>
Run Code Online (Sandbox Code Playgroud)