javascript - HTML5 Lives are not updating -


i have maze go through mouse , have function lives wich is

var life = 3; function lives(){ life --; } 

the way displaying lives is

<script type="text/javascript">     document.write("<div id='hp'>" + "lives: " + life + "</div>"); </script> 

i calling function these blocks arnt updating lives help! <img id="a1" src="blackpixel.png" onmouseover="lives()"/>

your onmouseover update value of variable lives, not update display of lives. can add line after line --;:

document.getelementbyid('hp').innerhtml = 'lives: ' + life; 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -