HTMLElement id Property
HTMLElement Object
Definition and Usage
The id property sets or returns the id of an element.
Syntax
Browser Support

The id property is supported in all major browsers.
Example
Example
Output the id of a link:
<html>
<body>
<p><a id="myAnchor"
href="http://www.w3schools.com">Visit W3Schools.com</a></p>
<script>
var
x=document.getElementById("myAnchor");
document.write(x.id);
</script>
</body>
</html>
Try it yourself »
HTMLElement Object
Thank You For Helping Us!
Your message has been sent to W3Schools.
Close [X]