Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
 <h1>The Element Object</h1>
<h2>The innerHTML Property</h2>
<p><a id="myAnchor" target="_blank" href="https://www.microsoft.com">Microsoft</a></p>
<button onclick="myFunction()">Change the link</button>
 
<script>
function myFunction() {
  const element = document.getElementById("myAnchor");
  element.innerHTML = "W3Schools";
  element.href = "https://www.w3schools.com";
}
</script>
</body>
</html>