why does page reload on button click code example

Example 1: how to refresh page on click of button

<button type="button" onClick="refreshPage()">Close</button>


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

Example 2: javascript button onclick reload page

const reloadtButton = document.querySelector("#reload");
// Reload everything:
function reload() {
    reload = location.reload();
}
// Event listeners for reload
reloadButton.addEventListener("click", reload, false);

Tags:

Misc Example