構文
var result = element.hasAttributes();
返値
result
- 返値を
true
またはfalse
で保持します。
例
let 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);
仕様書
仕様書 | 状態 | 備考 |
---|---|---|
DOM Element.hasAttributes() の定義 |
現行の標準 | Node インターフェイスからもっと具体的な Element インターフェイスへ移動した |
Document Object Model (DOM) Level 3 Core Specification hasAttributes() の定義 |
廃止された | Document Object Model (DOM) Level 2 Core Specification から変更なし |
Document Object Model (DOM) Level 2 Core Specification hasAttributes() の定義 |
廃止された | Node インターフェイス上で初回定義 |
ブラウザーの互換性
BCD tables only load in the browser