Attribute isId Property - Javascript DOM

Javascript examples for DOM:Attribute

Description

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

This property is read-only.

Return Value

A Boolean, returns true if the attribute is of type ID, otherwise false

The following code shows how to Find out if an attribute is the element's ID attribute or not:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="demo">P element</p>

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

<script>
function myFunction() {//  www.  ja v  a2  s .c o  m
    var x = document.getElementById("demo");
    x.innerHTML = x.attributes[0].isId;
}
</script>

</body>
</html>

Related Tutorials