---
title: Element.hasAttributes()
slug: Web/API/Element/hasAttributes
translation_of: Web/API/Element/hasAttributes
---
<div>{{ApiRef("DOM")}}</div>

<p>Метод <code><strong>Element</strong></code><strong><code>.hasAttributes()</code></strong> возвращает <strong>Boolean</strong> значение, указывая содержит данный элемент какие-либо атрибуты или нет.</p>

<h2 id="Синтаксис">Синтаксис</h2>

<pre>var<em><var> result</var></em> = <em><var>element</var></em>.hasAttributes();</pre>

<dl>
 <dt><code>result</code></dt>
 <dd>содержит возвращаемое значение <code>true</code> или <code>false</code>.</dd>
</dl>

<h2 id="Example">Пример</h2>

<pre class="brush:js">var foo = document.getElementById("foo");
if (foo.hasAttributes()) {
    // do something with 'foo.attributes'
}
</pre>

<h2 id="Polyfill">Polyfill</h2>

<pre class="brush:js">;(function(prototype) {
    prototype.hasAttributes = prototype.hasAttributes || function() {
        return (this.attributes.length &gt; 0);
    }
})(Element.prototype);
</pre>

<h2 id="Спецификация">Спецификация</h2>

{{Specifications}}

<h2 id="Совместимость_с_браузерами">Совместимость с браузерами</h2>

<p>{{Compat}}</p>

<h2 id="Смотрите_также">Смотрите также</h2>

<ul>
 <li>{{domxref("Element.attributes")}}</li>
 <li>{{domxref("Element.hasAttribute()")}}</li>
</ul>