jQuery Redirect Page 4 Sec

In our example, we will use 2 seconds to redirect to another page by creating a button. After clicking on the created button “Redirected”, the countdown will be started, and that button will redirect to entered url page after 5 seconds. The following example shows us the redirection to another given url page in jQuery.

Example:

    <input type="button" id="btnRedirect" value="Redirect" />  
    <br />  
    <br />  
    <div id="dvCountDown" style="display: none">  
    You will be redirected after <span id="lblCount"></span>&nbsp;seconds.  
    </div>  
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>  
    <script type="text/javascript">  
    $(function () {  
        $("#btnRedirect").click(function () {  
            var seconds = 5;  
            $("#dvCountDown").show();  
            $("#lblCount").html(seconds);  
            setInterval(function () {  
                seconds--;  
                $("#lblCount").html(seconds);  
                if (seconds == 0) {  
                    $("#dvCountDown").hide();  
                    window.location = "http://www.jqueryfaqs.com/";  
                }  
            }, 1000);  
        });  
    });  
    </script>  

The output of the above example is as follows:

Redirect

After click on this, we will be redirected to another page. Consider the following screenshot:

J QUERY
www.000webhost.com