Can anyone help me with the one of my doubts?
while reading jquery tutorials online, i come across some terms which I dont have the right understanding about.
for eg: “Default action”, “bubbling up” etc.
So, when we say cancel a default action and prevent it from bubbling up for the below code:
$("a").live("click", function() { return false; })
what is the default action here? does it mean cancelling the “live” action when they say cancel a default action? Also, if it needs to be cancelled why use it at the first place?
Also, what does “prevent it from bubbling up” mean?
Any help would be appreciated.
It’s regular browser’s handler of the clicking on the link – which causes changing url in address bar
No it doesn’t.
return false;prevents default action which is a regular click on the link, which leads to changing the page (usually)You can cancel in any place of the handler, doesn’t matter
If you don’t prevent the event from bubbling – it will bubble up by the DOM tree from the current element to the root.