hi,
as a question title i can use one of two techniques :
1- event.preventDefault()
[code]
$(‘a’).click(function (e) {
// custom handling here
e.preventDefault();
});
[/code]
2- return false
[code]
$(‘a’).click(function () {
// custom handling here
return false;
});
[/code]
what i need to know is is there any major difference between those two methods of stopping event propagation?
thanks.
return false from within a jQuery event handler is effectively the same as calling both e.preventDefault and e.stopPropagation on the passed jQuery.Event object.
e.preventDefault() will prevent the default event from occuring, e.stopPropagation() will prevent the event from bubbling up and return false will do both. Note that this behaviour differs from normal (non-jQuery) event handlers, in which, notably, return false does not stop the event from bubbling up
Source: John Resig