<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>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_element_id2 by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:02:19 GMT -->
</html>