我目前正在尝试更改单击时子元素的颜色。父元素链接到另一个页面。我希望 stopPropogation 会起作用,但事实并非如此。以下是我的 jQuery 代码:
$('.child').click(function(){
if($(this).hasClass('pinned')){
$(this).removeClass('pinned')
}
else{
$(this).addClass('pinned')
}
});
// disable parent link when pinning
$('.child').click(function(event){
event.stopPropagation();
});
如果重要的话,锚标签会围绕祖父母。
我哪里错了?