-2

I need to add a 2000ms delay to the following javascript. How do I do so.

<script type="text/javascript">
$(document).ready(function() {
  $("#container_main").hide();
});
$(window).load(function() {
  $("#container_main").show();
});
</script>

1 Answers1

0

Try something like this. Here you can put delay in ms(in following i have put 3000)

   var temp1=setInterval(function(){$("#div1").show();},3000);

Then you can clear it using . In case you don't clear it will keep executing after every 3000 ms.

clearInterval(temp1);

Ex:-

$(document).ready(function() {
    var temp1 = setInterval(function() {
        $("#container_main").hide();
        clearInterval(temp1);
    }, 3000);
});
Amulya
  • 182
  • 1
  • 12