English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

The HTML DOM hasAttributes() Method

HTML DOM Element Object

hasAttributes()The attribute returns a boolean value true or false to indicate whether the current element node has at least one attribute (attribute).

Syntax:

element.hasAttributes()
var p = document.getElementsByTagName("P")[0];
p.hasAttributes();
Test See‹/›

Browser Compatibility

All browsers fully support the hasAttributes() method:

Method
hasAttributes()YesYesYesYesYes

Technical Details

Return Value:Boolean value, returns true if the element has any attributes, otherwise returns false
DOM Version:DOM 2Level

Related References

HTML Tutorial:HTML Attributes

HTML DOM Reference:hasAttribute() Method

HTML DOM Reference:getAttribute() Method

HTML DOM Reference:setAttribute() Method

HTML DOM Reference:removeAttribute() Method

HTML DOM Element Object