Stop href event bubbling
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);
精彩评论