How to refresh a page using jQuery

In this post, we will see how to refresh a page using jQuery.
You can use location.reload() method of jQuery to reload the page. It is same as pressing f5 for refreshing a page.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Reload/Refresh a Page in jQuery</title>
    <script type="text/javascript"
        src="http://code.jquery.com/jquery-latest.js">
    </script>
 
    <script type="text/javascript">
        $(document).ready(function() {
            $('#reload').click(function() {
                location.reload();
            });
        });     
    </script>
</head>
<body>
    <input id="reload" type="button" value="reload" />
</body>
</html>
Let me know if it works for your browser or not.

Written by Arpit:

If you have read the post and liked it. Please connect with me on Facebook | Twitter | Google Plus

 

Java tutorial for beginners Copyright © 2012