我有
<a href="test.php?id=2" class="confirm_delete">Click to proceed</a>
并遵循 javascript。当我单击上面的链接时,它会显示带有 2 个按钮的对话框。“返回错误;” 停止链接标签的默认事件。但是我需要当我单击“是,删除”时通过选择 onclicked 锚点的 href 值将我带到其他页面的功能。我试过 alert($(this).attr('id')); (因为我认为我可以使用“this.attr('href')”获取 HREF 值)但它显示“对话框”。
我如何使它工作,以便当我单击具有类名“confirm_delete”的链接时,它会显示我的对话框,如果我单击取消它会停留在页面上,否则会根据 href 值将我带到页面。
$(".confirm_delete").click(function(){
$('<div id="dialog">Are you sure you want to delete?</div>').appendTo('body');
$("#dialog").dialog({
bgiframe: true, resizable: false, height:140, modal: true,
overlay: {
backgroundColor: '#000', opacity: 0.5
},
buttons: {
'Yes, Delete all items in recycle bin': function() {
$(this).dialog('close');
$(this).remove();
alert($(this).attr('id'));
},
Cancel: function() {
$(this).dialog('close');
$(this).remove();
}
}
});
return false;
});
谢谢你。