I want to add a class to a div after 2 seconds of the pageload

8.6k Views Asked by At

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.

1

There are 1 best solutions below

0
Bharat On BEST ANSWER

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>