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
Post a Comment