HTML DOM Element hasAttributes() method
- Previous page hasAttribute()
- Next page hasChildNodes()
- Go back to the previous level HTML DOM Elements Object
Definition and usage
If the specified node has attributes, then hasAttributes()
The method returns true
, otherwise returns false
.
If the specified node is not an element node, the return value is always false
.
See also:
Tutorial:
Example
Does the <body> element have attributes?
let answer = document.body.hasAttributes();
Syntax
element.hasAttributes()
or
node.hasAttributes()
Parameter
None.
Return value
Type | Description |
---|---|
Boolean value | Returns true if the element has attributes, otherwise false. |
Browser support
element.hasAttributes()
It is a DOM Level 2 (2001) feature.
All browsers fully support it:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | 9-11 | Support | Support | Support | Support |
- Previous page hasAttribute()
- Next page hasChildNodes()
- Go back to the previous level HTML DOM Elements Object