XML DOM hasAttributes()Methods
Element object
Definition and Usage
The hasAttributes() method returns TRUE if the current element node has attributes, otherwise it returns FALSE.
Syntax
hasAttributes()
Example
The following code snippet usesloadXMLDoc()put "books.xml" Load into xmlDoc, and check whether the returned first <book> element has attributes:
Example
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book')[0];
document.write(x.hasAttributes());
x=xmlDoc.getElementsByTagName('book')[0];
document.write(x.hasAttributes());
Output:
true
Try it Yourself »
Element objectother extensions