javascript - Why can't I stop this js click event propogation -
i'm trying override click handler intercepting event in inline handler , stopping propagation (propogation disabling code taken here).
the following code not doesn't stop propagation, it's not firing inline handler. can't tell what's wrong.
fiddle: http://jsfiddle.net/trkn4/3/
html:
<a onclick='stopit(event);'>do it</a> js:
function disableeventpropagation(event) { if (event.stoppropagation){ event.stoppropagation(); } else if(window.event){ window.event.cancelbubble=true; } } function stopit(event) { disableeventpropagation(event); alert('dont it'); } $(function() { $('a').click(function(e){ alert('im doing it'); }); });
it's not firing inline function because jsfiddle wrapping code in onload handler, taking out of reachable scope of handler.
choose no wrap option menu on left.
demo: http://jsfiddle.net/trkn4/4/

Comments
Post a Comment