Latest web development tutorials

HTML DOM hasAttributes method

Elements Object Reference Element object

Examples

See if there is any body element properties

document.body.hasAttributes()

Output:

false

try it"

Definition and Usage

hasAttributes () method returns true if a node has any attributes, otherwise returns false.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support hasAttributes method

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


grammar

node.hasAttributes()

parameter

None

return value

类型 描述
Boolean 如果节点有属性返回 true,否则返回false

technical details

DOM version Core Level 2 Node Object


Elements Object Reference Element object