XML DOM hasAttributes() method
Definition and usage
The hasAttributes() method returns true if any attributes are used in a node, otherwise it returns false.
Syntax:
nodeObject.hasAttributes()
Example
In all examples, we will use the XML file books.xml, and JavaScript functions loadXMLDoc().
The following code snippet can return whether the first <book> element is used for any attributes:
xmlDoc=loadXMLDoc("books.xml");
var x=xmlDoc.getElementsByTagName('book')[0];
document.write(x.hasAttributes()
);
Output:
true