javascript - Looping within functions -


i'd repeat piece of code 2 second interval inbetween, how so?

$(document).keydown(function(e) {       kkeys.push( e.keycode );       if ( kkeys.tostring().indexof( konami ) >= 0 ) {         $(document).unbind('keydown',arguments.callee);             $('.preview').attr('style', 'background: #'+math.floor(math.random()*16777215).tostring(16) + ';');       }     }); 

with being repeated:

$('.preview').attr('style', 'background: #'+math.floor(math.random()*16777215).tostring(16) + ';'); 

you want use conjunction of

settimeout()

with recursive call function , proper base case.

you can keep argument total time elapsed , use want. can use

setinterval() 

that should put on right track


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -