Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM hasAttributes method

HTML DOM hasAttributes() method

Element Object Reference Element object

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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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 Reference Element object