Tuesday, January 21, 2014

JavaScript Timer sample to hide a loading image after some seconds

A simple code to perform the timer functionality in Javascript. In the following example initially i have shown loading image using JQuery show() function. Then using the window.setInterval function i have set the Timer time to 5000 microseconds ie, 5 seconds. So the Hide function will execute after 5 seconds and the loading image will be hidden using the JQuery  hide() function. The JQuery show() and hide() function is equivalent to the CSS display block and none.
JavaScript Code:

  1. <script type="text/javascript">
  2. $('.img').show();
  3. window.setInterval(Hide, 5000);
  4. function Hide()
  5. {
  6.         $('.img').hide();
  7.  
  8. }
  9. </script>

No comments:

Post a Comment