HTML DOM id property
Definition and Usage
The id property sets or returns the id of an element.
Syntax
HTMLElementObject.id=
id
Browser support





All major browsers support the id property
Example
Example
Output the id of the link:
<!DOCTYPE html><html>
<head>
<meta charset="utf-8">
<title>Runoob Tutorial(runoob.com)
title
head
<body>
<p>
<a id="myAnchor" href="//www.runoob.com">Visit the Runoob Tutorial
a
p
<
script
var x=document.getElementById("myAnchor"); document.write(x.id);
script
body
html
Try it »
Element object