I want to add a class to a div after 2 seconds of the pageload, please guide me how can I do it with jquery.
            Asked
            
        
        
            Active
            
        
            Viewed 8,079 times
        
    0
            
            
        - 
                    jQuery isn't needed here: [`setTimeout()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout) – Rory McCrossan Nov 09 '16 at 10:09
 
1 Answers
2
            You can try like this.$(window).ready(function(){}) will not call till your whole page will be ready and setInterval() will call after 2 sec.
$(window).ready(function(){
  setInterval(function(){ 
    $('div').addClass("test")
  }, 2000);
});
<div>Class
</div>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
        Bharat
        
- 2,441
 - 3
 - 24
 - 36