The isId
property returns true if
the attribute is of type ID, otherwise it returns false.
isId |
Yes | No | Yes | Yes | No |
attribute.isId
A Boolean, true or false.
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: