There is such HTML:

<div class="asd"> <div class="das selected"></div> <div class="das"></div> <div class="das"></div> <div class="das"></div> <div class="das"></div> </div> 

Every 5 seconds, selected blocks change, and there is a code like this:

 $(function() { $(".asd").html('<span class="disb"></span>'); $(".asd.selected").html('<span class="act"></span>'); }); 

How to make the script work out always, and not just when the document is loaded?

  • It is not clear how now something “changes every 5 seconds”? In the above code, after the execution, all internal div 's will disappear and instead they will only <span class="disb"/> - Sergiks

1 answer 1

 window.setInterval( function(){ $(".asd").html('<span class="disb"></span>'); $(".asd.selected").html('<span class="act"></span>'); } , 5000 ) 

Every 5 seconds the function will be executed.