jquery - Two function and alert not working? -


html code

<body> <h1 align="center">are ready?</h1> <h2 align="center">just answer yes or no!</h2> <div class="wrapper">     <button id="ohyes" class="buttonyes"> yes </button>     <button id="ohno" class="buttonno"> no </button> </div> </body> 

jquery code

<script> $(function () {     $("#ohno").on({         mouseover: function () {             $(this).css({                 left: (math.random() * 800) + "px",                 right: (math.random() * 800) + "px",                 top: (math.random() * 400) + "px",             });         }      });      $("#ohyes").click(function () {         alert("yes"); //use .val() if you're getting value     }); }); </script> 

i'm trying call function in jquery first working fine button moving on mouseover when click button having id ohyes isn't showing alert box? suggestions?

try : alert on second button ohyes on click event.

$(document).ready(function(){     $("#ohno").mouseover(function(){         $(this).css({             left:(math.random()*800)+"px",             right:(math.random()*800)+"px",             top:(math.random()*400)+"px",         });     });      $("#ohyes").click(function(){           alert("yes");  //use .val() if you're getting value     });   }); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -