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/getattributens/index.html | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 files/ja/web/api/element/getattributens/index.html (limited to 'files/ja/web/api/element/getattributens') diff --git a/files/ja/web/api/element/getattributens/index.html b/files/ja/web/api/element/getattributens/index.html new file mode 100644 index 0000000000..974483920a --- /dev/null +++ b/files/ja/web/api/element/getattributens/index.html @@ -0,0 +1,47 @@ +--- +title: element.getAttributeNS +slug: Web/API/Element/getAttributeNS +tags: + - DOM + - Gecko + - 翻訳中 +translation_of: Web/API/Element/getAttributeNS +--- +

{{ ApiRef("DOM") }}

+ +

概要

+ +

getAttributeNS は指定の名前空間と名前の属性の文字列値を返します。もし指定の名前の属性が存在しなければ、戻り値は null または ""(空文字列) のいずれかとなります。詳細は{{ Anch("注記") }} を参照。

+ +

構文

+ +
attrVal =element.getAttributeNS(namespace,name)
+
+ +

引数

+ + + +

+ +
var div1 = document.getElementById("div1");
+var a = div1.getAttributeNS("www.mozilla.org/ns/specialspace/",
+                            "special-align");
+alert(a); // div の align 属性の値を表示します。
+
+ +

注記

+ +

getAttributeNSgetAttribute と異なります。getAttributeNS は特定の名前空間に属している要求された属性をより深く特定することができます。上記の例では、属性は mozilla の架空の "specialspace" 名前空間に属しています。

+ +

DOM4 より前の仕様では、このメソッドは属性が存在しない場合に null ではなく空文字列を返すように指定されていました。しかし、ほとんどのウェブ・ブラウザは null を返していました。DOM4 以降は、仕様でも null を返すように指定されました。しかしながら、いくつかの古いウェブ・ブラウザは空文字列を返します。そのため、指定の要素に指定の属性が存在しない可能性があるなら getAttributeNS を呼ぶ前に hasAttributeNS を使用して属性の存在を確かめる必要があります。

+ +

{{ DOMAttributeMethods() }}

+ +

仕様

+ +

DOM Level 2 Core: getAttributeNS

-- cgit v1.2.3-54-g00ecf