javascript refresh div on click – How to refresh a page by jQuery/JavaScript?

Rate this post

javascript refresh div on click – The default value is false that may simply refresh the web page from the any browser cache.

javascript refresh div on click

Onclick reload the div only reload/refresh the div itself and not load a php file. Example: refresh page on div click.

refresh page on div click

<div id="refresh" onClick="refreshPage()">refresh
    <!-- <button type="button" onClick="refreshPage()">Close</button> -->
</div>

<script>
function refreshPage(){
    window.location.reload();
} 
</script>

How do I refresh a DIV content?

<div id='liveScore'></div>

Free Live Chat for Any Issue

jquery code

<script type='text/javascript'>
    function updateDiv()
    { 
        document.getElementById("liveScore").innerHTML = document.getElementById("liveScore").innerHTML ;
    } 
</script>


and (for a every 3 second refresh) :
$(document).ready(function () {
    setInterval(function () {
        $('#liveScore').load('#liveScore'));
    }, 3000);
});

Don’t Miss : Jquery Reload Page Automatically Example

Read Also:  Validate Email and Password Fields on Form Submit Event

function GetScore () {document.getElementById("liveScore").innerHTML.reload}

function GetScore () {$('#liveScore').load(self)} 

<a onclick='GetScore ();'>reload div</a>

Best Solution

function updateDiv()
{ 
    $( "#liveScore" ).load(window.location.href + " #liveScore" );
}

JavaScript – Function to Refresh Page on Button Click

Refresh Webpage on Button Click

<script type="text/javascript">
    function refreshPage() {
        if (confirm("Are you sure, want to refresh?")) {
            location.reload();
        }
    }
</script>

HTML Source Code with JavaScript:

JavaScript – Function to Refresh Page on Button Click.

<html>
    <head>
        <title>JavaScript - Function to Refresh Page on Button Click. - www.pakainfo.com</title>
        <script type="text/javascript">
            function refreshPage() {
                if (confirm("Are you sure, want to refresh?")) {
                    location.reload();
                }
            }
        </script>
    </head>

    <body style="text-align: center;">
        <h2>JavaScript - Function to Refresh Page on Button Click.</h2>
        <p><input type="button" value="Refresh Webpage." onclick="refreshPage()" /></p>
    </body>
</html>

Download

I hope you get an idea about javascript refresh div on click.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.