HTML DOM hasAttributes()Method

元素对象参考手册Element Object

Examples

Check whether the body element has any attributes

document.body.hasAttributes()

Output result:

false

Try it Yourself »

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 versions of IE 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

Other Extensions