<!DOCTYPE html>
<html>
<body>
<h1>The Element Object</h1>
<h2>The id Property</h2>
<p><a id="myAnchor" href="https://www.w3schools.com/">W3Schools</a></p>
<p>Click "Change" to change the value of the id attribute of the link.</p>
<button onclick="changeID()">Change</button>
<p>The id of the link is:</p>
<p id="demo"></p>
<script>
function getID() {
document.getElementById("demo").innerHTML = element.id;
}
function changeID() {
element.id = "newid";
getID();
}
let element = document.getElementById("myAnchor");
getID();
</script>
</body>
</html>