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

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

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -