Find out if an attribute is the element's ID attribute or not:
var x = document.getElementById("demo").attributes[0].isId;
The isId property is not supported in any of the major browsers.
<!DOCTYPE html> <html> <body> <p id="demo"></p> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*from w w w .ja v a 2 s . co m*/ var x = document.getElementById("demo"); x.innerHTML = x.attributes[0].isId; } </script> </body> </html>
The isId property returns true if the attribute is of type ID, otherwise it returns false.
This property is read-only.