Element.hasAttributes()
構文
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);
仕様書
Specification |
---|
DOM Standard # ref-for-dom-element-hasattributes① |
ブラウザーの互換性
BCD tables only load in the browser