Javascript Reference - HTML DOM isId Property








The isId property returns true if the attribute is of type ID, otherwise it returns false.

Browser Support

isId Yes No Yes Yes No

Syntax

attribute.isId

Return Value

A Boolean, true or false.

Example

The following code shows how to find out if an attribute is the element's ID attribute.


<!DOCTYPE html>
<html>
<body>
<!--   w w w .ja  v  a 2  s .  co m-->
<p id="demo">ID attribute</p>

<button onclick="myFunction()">test</button>

<script>
function myFunction() {
    var x = document.getElementById("demo");
    x.innerHTML = x.attributes[0].isId;
}
</script>


</body>
</html>

The code above is rendered as follows: