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.
  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2. <head>
  3. <title>Reload/Refresh Page</title>
  4. <script type="text/javascript"
  5. src="http://code.jquery.com/jquery-latest.js">
  6. </script>
  7. <script type="text/javascript">
  8. $(document).ready(function() {
  9. $('#btn').click(function() {
  10. location.reload();
  11. });
  12. });
  13. </script>
  14. </head>
  15. <body>
  16. <input id="btn" type="button" value="button" />
  17. </body>
  18. </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.