このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

Element: hasAttributes() メソッド

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.

hasAttributes()Element インターフェイスのメソッドで、現在の要素が属性を持っているか否かを論理値で返します。

構文

js
hasAttributes()

引数

なし。

返値

論理値です。

js
let foo = document.getElementById("foo");
if (foo.hasAttributes()) {
  // Do something with 'foo.attributes'
}

仕様書

Specification
DOM
# ref-for-dom-element-hasattributes①

ブラウザーの互換性

関連情報