开发者

Stop href event bubbling

开发者 https://www.devze.com 2023-04-11 15:27 出处:网络
I\'m creating a td tag from javascript. It has an addEventListener/attachEvent set for clicks. Inside this tag I have an inner w开发者_Go百科ith \'a\' tag. I need to run the href without triggering th

I'm creating a td tag from javascript. It has an addEventListener/attachEvent set for clicks. Inside this tag I have an inner w开发者_Go百科ith 'a' tag. I need to run the href without triggering the td click. Until now i have it working in IE:

cell1.innerHTML = "<a href='"+url+"' onclick='event.cancelBubble = true; 
if(event.stopPropagation) { event.stopPropagation(); }'>"


I've got it working in chrome by setting the catch event to bubble (the 'false' statement)

cell.addEventListener("click", function(){          
        ...},false);    
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号