XML DOM hasAttribute() Method
Element Object
Definition and Usage
The hasAttribute() method returns TRUE if the current element node has an attribute matching the specified name, otherwise it returns FALSE.
Syntax
hasAttribute(name)
| Parameters | Description |
|---|---|
| name | Required. Specifies the attribute to look for. |
Example
The following code snippet uses loadXMLDoc() to load "books.xml" into xmlDoc, and check whether the first
Example
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName("book")[0];
document.write(x.hasAttribute("category"));
Output:
true
Try it »
Element Object