diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/api/element/hasattribute/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/ja/web/api/element/hasattribute/index.html')
-rw-r--r-- | files/ja/web/api/element/hasattribute/index.html | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/files/ja/web/api/element/hasattribute/index.html b/files/ja/web/api/element/hasattribute/index.html new file mode 100644 index 0000000000..1999a7a802 --- /dev/null +++ b/files/ja/web/api/element/hasattribute/index.html @@ -0,0 +1,49 @@ +--- +title: element.hasAttribute +slug: Web/API/Element/hasAttribute +tags: + - DOM + - DOM Element Methods + - Gecko +translation_of: Web/API/Element/hasAttribute +--- +<div>{{ApiRef}}</div> + +<h2 id="Summary" name="Summary">概要</h2> + +<p>hasAttribute</p> + +<p>は指定の要素が指定の属性を持つか否かを示す真偽値を返します。</p> + +<p> </p> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox"><var>var result</var> = <var>element</var>.hasAttribute(<var>attName</var>); +</pre> + +<ul> + <li><code>result</code> : true または false の戻り値を保有</li> + <li><code>attName</code> : 属性の名前を表す文字列を指定</li> +</ul> + +<h2 id="Example" name="Example">例</h2> + +<p>対象属性の存在をチェックし、無い場合にのみ属性を設定する例を以下に示します。</p> + +<pre class="brush:js;highlight:[4]">var d = document.getElementById("div1"); // 対象要素を取得 + +if ( !d.hasAttribute("align") ) { + d.setAttribute("align", "center"); +}</pre> + +<h2 id="Notes" name="Notes">注記</h2> + +<div>{{DOMAttributeMethods}}</div> + +<h2 id="Specification" name="Specification">仕様書</h2> + +<ul> + <li><a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-ElHasAttr">DOM Level 2 Core: hasAttribute</a></li> + <li><a href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-ElHasAttr">DOM Level 3 Core: hasAttribute</a></li> +</ul> |