Adding onclick event to td, but should not fire on links within
I have this:
$('table.data td').click(function() {
}
But the problem is this also fires when I click on links within that column. How can I prevent that?
Tried something like table.data td :not(a)
but that doesn't seem to work at all..
Thanks.
--
Nevermind, just found ou开发者_Python百科t about e.target.nodeName! (if that is the best way to deal with this: != 'A')
You can stop the event propagation for the children nodes this way:
$('table.data td a').click(function(evt){
evt.stopPropagation();
[.. Do other stuff ..]
});
jquery stopPropagation() Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event.
精彩评论