Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XML DOM hasAttributes() Method

XML DOM hasAttributes() Method


Node Object Reference Node object


Definition and Usage

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

Syntax

nodeObject.hasAttributes()


Example

The following code snippet uses loadXMLDoc() to load "books.xml" into xmlDoc, and return whether the first element has any attributes:

Example

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.getElementsByTagName('book')[0];

document.write(x.hasAttributes());

Output:

true

Try it »


Node Object Reference Node object