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 -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -