我在另一个里面有两个分数。现在我想要点击内部divison,点击外部divison进行的工作是停止的。但我不知道我的代码是什么问题。这就是它:
$(document).ready(function() {
$('.notification_one').click(function() {
alert($(this).attr("id"));
location.href = 'shownotification.jsp?notifyidd=' + $(this).attr("id");
});
$('.detele_notification').click(function() {
DoRemove(event);
alert("cross clicked" + $(this).attr("id"));
var surity = confirm("Are you sure you want to delete this Notification? ");
if (surity == true) {
location.href = 'deletenotification?idss='+$(this).attr("id");
}
});
});
function DoRemove(e){
if (!e)
var e = window.event;
e.cancelBubble = true;
if (e.stopPropagation)
e.stopPropagation();
}
这里的notification_one是外部divison,而detele_notification是内部的。请帮助。
答案 0 :(得分:0)
您的DoRemove()
函数中有代码停止传播,但您没有在点击处理程序中包含该事件:
$('.detele_notification').click(function (e) { // Note 'e' here
e.stopPropagation(); // stop the click bubbling here
alert("cross clicked" + $(this).attr("id"));
var surity = confirm("Are you sure you want to delete this Notification? ");
if (surity == true){
location.href = 'deletenotification?idss='+$(this).attr("id");
}
});