I bind to a link (by using the .live()
function of jQuery) click
event and then manually add an onclick
event handler with pure JS and HTML (like <a href="".... onclick="some action">
). I want to prevent bubbling of the event to the live
method but I don't know how.
Maybe e.stopPropagation()
is helpful in this situation but the event handler added with onclick
is written in pure JS and I can't call stopPropagation()
from outside the jQuery element wrapper. return false
in this situation does not work. I tried to substitute return false
with $.Event('click').stopPropagation()
but I think this is wrong as it did not work.
How to prevent bubling to live()
method without jQuery wrapper?
return false
should do the trick. It should work if you do:<a href="".... onclick="some action; return false;">
. Btw.event.stopPropagation()
is not a jQuery method. The problem is that IE uses a different event modle that does not offer this method, soreturn
ingfalse
is the best solution ins this case. The question is, why do you use inline event handlers at all? – Currency