--- title: Element.hasAttributes() slug: Web/API/Element/hasAttributes translation_of: Web/API/Element/hasAttributes ---
Метод Element.hasAttributes() возвращает Boolean значение, указывая содержит данный элемент какие-либо атрибуты или нет.
var result = element.hasAttributes();
resulttrue или false.var foo = document.getElementById("foo");
if (foo.hasAttributes()) {
// do something with 'foo.attributes'
}
;(function(prototype) {
prototype.hasAttributes = prototype.hasAttributes || function() {
return (this.attributes.length > 0);
}
})(Element.prototype);
| Specification | Status | Comment |
|---|---|---|
| {{SpecName("DOM WHATWG", "#dom-element-hasattributes", "Element.hasAttributes()")}} | {{Spec2('DOM WHATWG')}} | Moved from the {{domxref("Node")}} interface to the more specialized {{domxref("Element")}} interface. |
| {{SpecName('DOM3 Core','#ID-NodeHasAttrs','hasAttributes()')}} | {{Spec2('DOM3 Core')}} | No change from {{SpecName("DOM2 Core")}} |
| {{SpecName('DOM2 Core','#ID-NodeHasAttrs','hasAttributes()')}} | {{Spec2('DOM2 Core')}} | Initial definition, on the {{domxref("Node")}} interface. |
{{ CompatibilityTable() }}
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | {{ CompatVersionUnknown() }} | {{ CompatVersionUnknown() }} [1] | 9 | {{ CompatVersionUnknown() }} | {{ CompatVersionUnknown() }} |
| Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Basic support | {{ CompatUnknown() }} | {{ CompatUnknown() }} | {{ CompatUnknown() }} | {{ CompatUnknown() }} | {{ CompatUnknown() }} | {{ CompatUnknown() }} |
[1] Before Firefox 35, it was implemented on the {{domxref("Node")}} interface.