Search w3schools.com:

SHARE THIS PAGE

DOM Node hasAttributes() Method

Node Object Reference Node Object

Example

See if the body element has any attributes:

document.body.hasAttributes()

The result will be:

false

Try it yourself »

Definition and Usage

The hasAttributes() method returns true if the specified node has any attributes, otherwise false.

If the specified node is not an Element node, the return value is always false.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The hasAttributes() method is supported in all major browsers.

Note: Internet Explorer 8 and earlier does not support this method.


Syntax

node.hasAttributes()

Parameters

None

Return Value

Type Description
Boolean true if the node has attributes, otherwise false

Technical Details

DOM Version Core Level 2


Node Object Reference Node Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]