javascript - Mousemove event firing even if mouse is still. Is there something wrong with the code? -


i'm trying make when move mouse stop/start button appears. except button fires several times after movement if mouse still. know if error in code, if there lacking, or if has nothing code, rather external issue? options?

i'm not experienced coding appreciated. thanks.

html

<div id="start-stop"></div> 

css

#start-stop {     width: 300px;     height: 300px;     background-image: url(pause.gif);     cursor: pointer;      z-index: 999;     position: absolute;     top: 50%;     left: 50%;     margin: -150px 0 0 -150px; } 

script

 $(document).ready(function() {     $("#start-stop").fadeout(3000);     rndtext();     inter = setinterval(function() {          rndtext();       }, 5000);  });  $("body").mousemove(function() {     $("#start-stop").finish().show().fadeout(1500); });  $(document).on('click', '#start-stop', function(){   if (intervalrunning) {     intervalrunning = false;     clearinterval(inter);     $(this).css('background-image', 'url(play.gif)').fadeout(1500);   } else {     intervalrunning = true;     $(this).css('background-image', 'url(pause.gif)').fadeout(1500);     inter = setinterval(function() {       rndtext();     }, 3000);   } }) 


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

post - imageshack API cURL -