HTML DOM id attribute
Definition and Usage
id attribute or set back the element id.
grammar
HTMLElementObject.id=id
Browser Support
All major browsers support the id attribute
Examples
Examples
Output link id:
<html>
<body>
<p><a id="myAnchor"
href="http://www.w3cschool.cc">Visit W3CSchool.cc</a></p>
<script>
var x=document.getElementById("myAnchor");
document.write(x.id);
</script>
</body>
</html>
<body>
<p><a id="myAnchor"
href="http://www.w3cschool.cc">Visit W3CSchool.cc</a></p>
<script>
var x=document.getElementById("myAnchor");
document.write(x.id);
</script>
</body>
</html>
try it"