Latest web development tutorials

HTML DOM id attribute

Elements Object Reference Element object


Definition and Usage

id attribute or set back the element id.

grammar

HTMLElementObject.id=id


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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>

try it"


Elements Object Reference Element object