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:

<script type="text/javascript">
$('.img').show();
window.setInterval(Hide, 5000);
function Hide()
{
        $('.img').hide();

}
</script>

No comments:

Post a Comment