Latest web development tutorials

XML DOM hasAttributes () method

Element Object Reference Element object

Definition and Usage

hasAttributes () method returns TRUE if the current element nodes have attributes, otherwise it returns FALSE.

grammar

hasAttributes()


Examples

The following code fragment uses loadXMLDoc () to " the Books.xml " into xmlDoc and check returns the first <book> element has attributes whether:

Examples

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

document.write(x.hasAttributes());

Output:

true

try it"

Element Object Reference Element object