XML DOM hasAttributes() method
Definition and usage
If the current element node has any attributes, hasAttributes() returns true, otherwise it returns false.
Syntax:
hasAttributes()
Example
In all examples, we will use the XML file books.xml, and JavaScript functions loadXMLDoc().
The following code snippet checks whether the first <book> element in "books.xml" has attributes:
xxmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book')[0];
document.write(x.hasAttributes()
);
The output of the above code is:
true