Edit This Code:
<!DOCTYPE html>
<html>
<body>

<p><a id="myAnchor" href="../index.html">W3Schools</a></p>

<p>Click the button to change the value of the id attribute of the link above to "newid".</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    document.getElementById("myAnchor").id = "newid";
    document.getElementById("demo").innerHTML = "The id of the link was changed from 'myAnchor' to 'newid'.";
}
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy