You are here: Reference > JavaScript > client-side > HTML DOM > properties > isId (attribute)

isId property (attribute)

Browser support:
Returns whether the current attribute node is an id attribute or not.
Note: The isId property is supported in Safari from version 5.
The isId property does not work in XML documents, only in HTML documents. For a cross-browser solution, use the value of the name property instead.


You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

Boolean that indicates whether the current name is an id attribute or not.
One of the following values:
The attribute is not an id attribute.
The attribute is an id attribute.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the isId property:
    <script type="text/javascript">
        function GetId () {
            var div = document.getElementById ("myDiv");
            for (var i=0; i < div.attributes.length; i++) {
                var attrNode = div.attributes[i];
                if ('isId' in attrNode) {
                    if (attrNode.isId) {
                        alert ("The value of the id attribute: " + attrNode.value);
                else {
                    var attrName = ();
                    if (attrName == "id") {
                        alert ("The value of the id attribute: " + attrNode.value);
    <button onclick="GetId ();">Get the value of the division element's id attribute!</button>
    <div id="myDiv">
        Division with id="div"
Did you find this example helpful? yes no

Supported by objects:

User Contributed Comments

Post Content

Post Content