Monday, October 6, 2014

Timer function jquery

This timer is a sample of jquery that is using a normal javascript function to refresh or auto load its content.
Function timer is very useful when we want our javascript function to rerun for an specified time.
 $(function () {
        var num = 1;
        
        //our function
        function theFunction(){        
            num++;
            $('.time').html(num);
        }        
        
        //run every 1 second      
        setInterval(theFunction, 1000);
 });
Live Demo

No comments:

Post a Comment