Repeat a JavaScript action every certain amount of clicks? -


i've made script calls function every 5 clicks on element. i'd repeat action every 5 clicks, , not call once. there way reset variable count when action called?

$(document).ready(function(){ var count=0; $(".logo").click(function(){     count+=1;     if (count==5) {         $( "body" ).toggleclass('easteregg');     }   }); }); 

you don't have reset do

if(count % 5 === 0){     //your code here } 

this called every time count multiple of 5


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -

What is happening when Matlab is starting a "parallel pool"? -