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


Element Object Reference Element Object


Definition and Usage

The hasAttributes() method returns TRUE when the current element node has attributes, otherwise it returns FALSE.

Syntax

hasAttributes()


Example

The following code snippet uses loadXMLDoc() to load "books.xml" Load into xmlDoc, and check 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 »


Element Object Reference Element Object