javascript - event object not defined only with Firefox (IE and Chrome works) -
this question has answer here:
- event.target not working on firefox 2 answers
<a class="lnk" href="#" onclick="showitem();"> <span data-id="27">test</span> </a> function showitem() { var itid = event.target.dataset.id; alert(itid); }
if try this jsfiddle code can see ie (11) , chrome event object correctly evaluated, firefox (32.0) error (referenceerror : event not defined)
it's bug of firefox or different event object lifecycle in ie , chrome ? since in ie , chrome it's working think it's problem. workaround ?
p.s: in jsfiddle, firefox, code selection still having problem (after run cannot select code.
you should pass event
argument function:
<a class="lnk" href="#" onclick="showitem(event);"> <span data-id="27">test</span> </a> function showitem(e) { e = e || window.event; var itid = e.target.dataset.id; alert(itid); }
accessing global variable ie feature chrome copied, don't think it's standard javascript.
Comments
Post a Comment