HTML DOM hasAttributes() method
Example
Check whether the body element has any attributes
document.body.hasAttributes()
Output result:
false
Try it »
Definition and Usage
The hasAttributes() method returns true if a node has any attributes, otherwise it returns false.
Browser support





All major browsers support the hasAttributes method
Note: Internet Explorer 8 and earlier IE versions do not support this method.
Syntax
node
.hasAttributes()
Parameters
None
Return Value
| Type | Description |
|---|---|
| Boolean | Returns true if the node has attributes, otherwise returns false |
Technical Details
| DOM version | Core Level 2 Node Object |
|---|
Element object