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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -