I have a button in my web page and I want to refresh or reload the page on button click event . I will use the following code for this.
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Reload/Refresh Page</title>
- <script type="text/javascript"
- src="http://code.jquery.com/jquery-latest.js">
- </script>
-
- <script type="text/javascript">
- $(document).ready(function() {
- $('#btn').click(function() {
- location.reload();
- });
- });
- </script>
- </head>
- <body>
- <input id="btn" type="button" value="button" />
- </body>
- </html>
The location.reload() method is used to refresh/reload the web page, so when we click on the button,
page will be refresh. It is similar to press the F5 button.