javascript refresh element code example

Example 1: refresh window js

window.location.reload();

Example 2: javascrpt refresh page

location.reload();

Example 3: javascript replace element

<html>
<head>
</head>
<body>
  <div>
    <a id="myAnchor" href="http://www.stackoverflow.com">StackOverflow</a>
  </div>
<script type="text/JavaScript">
  var myAnchor = document.getElementById("myAnchor");
  var mySpan = document.createElement("span");
  mySpan.innerHTML = "replaced anchor!";
  myAnchor.parentNode.replaceChild(mySpan, myAnchor);
</script>
</body>
</html>

Example 4: relode div

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

Example 5: refresh javascript

location.reload();
Works like refresh button.