Element: hasAttributes() method
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{ApiRef("DOM")}}
The **hasAttributes()** method of the {{domxref("Element")}} interface returns a boolean value indicating whether the current element has any attributes or not.
Syntax
js-nolint
hasAttributes()Parameters
None.
Return value
A boolean.
Examples
js
let foo = document.getElementById("foo");
if (foo.hasAttributes()) {
// Do something with 'foo.attributes'
}Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
- {{domxref("Element.attributes")}}
- {{domxref("Element.hasAttribute()")}}
- {{domxref("Element.getAttribute()")}}
- {{domxref("Element.setAttribute()")}}
- {{domxref("Element.removeAttribute()")}}
- {{domxref("Element.toggleAttribute()")}}