From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/element/hasattributes/index.html | 85 +++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 files/ja/web/api/element/hasattributes/index.html (limited to 'files/ja/web/api/element/hasattributes') diff --git a/files/ja/web/api/element/hasattributes/index.html b/files/ja/web/api/element/hasattributes/index.html new file mode 100644 index 0000000000..e221ac44d9 --- /dev/null +++ b/files/ja/web/api/element/hasattributes/index.html @@ -0,0 +1,85 @@ +--- +title: Element.hasAttributes() +slug: Web/API/Element/hasAttributes +tags: + - API + - DOM + - Element + - Method + - Reference + - メソッド +translation_of: Web/API/Element/hasAttributes +--- +
{{ApiRef("DOM")}}
+ +

hasAttributes() は {{domxref("Element")}} インターフェイスのメソッドで、現在の要素が属性を持っているか否かを {{jsxref("Boolean")}} で返します。

+ +

構文

+ +
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);
+
+ +

仕様書

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName("DOM WHATWG", "#dom-element-hasattributes", "Element.hasAttributes()")}}{{Spec2('DOM WHATWG')}} {{domxref("Node")}} インターフェイスからもっと具体的な {{domxref("Element")}} インターフェイスへ移動した
{{SpecName('DOM3 Core','#ID-NodeHasAttrs','hasAttributes()')}}{{Spec2('DOM3 Core')}} {{SpecName("DOM2 Core")}} から変更なし
{{SpecName('DOM2 Core','#ID-NodeHasAttrs','hasAttributes()')}}{{Spec2('DOM2 Core')}} {{domxref("Node")}} インターフェイス上で初回定義
+ +

ブラウザーの互換性

+ + + +

{{Compat("api.Element.hasAttributes")}}

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf