XML DOM hasAttributes()Methods


Node object

Definition and Usage

The hasAttributes() method returns true when the node has attributes, otherwise it returns false.

Syntax

nodeObject.hasAttributes()


Example

The following code snippet usesloadXMLDoc()put "books.xml" Load into xmlDoc, and return whether the first <book> element has attributes:

Example

xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book')[0];

document.write(x.hasAttributes());

Output:

true

Try it Yourself »

Node objectother extensions