by @kodeazy

JavaScript How to refresh the page on clicking in text?

Home » javascript » JavaScript How to refresh the page on clicking in text?
  • To refres the page on clicking we use window.location = window.location.href;.
  • Below is the sample example of refreshing the page on clicking.

    <!DOCTYPE html>
    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script>
    function refreshPage(){
        window.location = window.location.href;	
    }
    </script>
    </head>
    <body>
    <div onclick="refreshPage()" style="display: block; cursor: pointer;">click here to refresh</div>
    </body>
    </html>