javascript - why don't inline events with function names work on divs? -


i feel such noob question cannot life of me figure out.

http://jsfiddle.net/37pj3bro/5/

<div onclick="dingo()">click me</div> <div onclick="alert(this)">click me 2</div>  <script type="text/javascript"> function dingo() {     alert("hi"); } </script> 

the first click me not alert second 1 does. can't figure out why....

the code in question works fine:

<div onclick="dingo()">click me</div>  <div onclick="alert(this)">click me 2</div>    <script type="text/javascript">  function dingo()  {      alert("hi");  }  </script>

the code in js fiddle doesn't work because you've configured dingo not global.

screenshot


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -