Javascript/JQuery Math.random to onclick fade to -


i making simple game school project , basic idea when press button start game random images fade in , have click many of them can in 30 seconds. using math.random , javascript if statements , jquery built in onclick , fadeto. function not working , dont know why.here html

<!doctype html> <html> <head> <title>my test game</title> <!-- css --> <link rel="stylesheet" type="text/css" href="css/style.css"> </head> <body> <h1>click many can in 30 seconds</h1> <input id="clickme" type="button"  value="clickme"onclick="randomnumfunc();" /> <!-- game area --> <div id="game-area"> <div id="circle1"></div> </div> <!-- javascript/jquery --> <script src="js/jquery.js"></script> <script src="js/script.js"></script> </body> 

css:

body { background-color: #cef6f5; }  #game-area { border: 5px solid black; height: 500px; background-color: white; }  #circle1 { -moz-border-radius: 50px/50px; -webkit-border-radius: 50px 50px; border-radius: 50px/50px; border: solid 21px #f00; width: 50px; height: 50px;   opacity: 0.5; } 

and javascript/jquery:

/* rng variable */ var randomnum = math.floor((math.random() * 3) + 1);  /* picture assignments */ var pic1 = 1; var pic2 = 2; var pic3 = 3;  /* rng code */  function randomnumfunc() { document.getelementbyid('#circle1').innerhtml; if (randomnum == 1) { $(document).ready(function() {   $(document).fadeto('fast', 1); }); $(document).onclick(function() {   $(document).fadeto('fast', 0); }); } } 

your <input> element should be,

<input id="clickme" type="button" value="clickme"/>

and javascript/jquery code like,

$(document).ready(function() { var randomnum = math.floor((math.random() * 3) + 1);     $('#clickme').click(function(){       if(randomnum == 1){         $('#circle1').fadeto('fast', 1);       }     else{        $('#circle1').fadeto('fast', 0);      }     })  }); 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -