What is the jQuery equivalent to the following:
function stopEvent(evt) {
if (window.event) window.event.cancelBubble = true;
else evt.stopPropagation();
}
What is the jQuery equivalent to the following:
function stopEvent(evt) {
if (window.event) window.event.cancelBubble = true;
else evt.stopPropagation();
}
The jQuery Event object implements a stopPropagation method which is a cross-browser way to prevent events from bubbling up the DOM tree. Example:
// when an anchor with id of someElement gets clicked
$("#someElement").click(function(e) {
e.stopPropagation();
});
Bear in mind, return false has the same effect as calling both e.preventDefault() and e.stopPropagation().