Visit Mozilla.org

DOM:element.id

出典: MDC

« Gecko DOM リファレンス

目次

[編集] 概要

要素の識別子(identifier)を取得(get)または設定(set)します。

[編集] 構文

idStr = element.id
element.id = idStr

この場合 idStr は要素のIDです。

[編集] 注意

IDはドキュメント内でユニークでなくてはならず、document.getElementByIdを使って要素を取り出すために使われることがあります。

document によっては(特に, HTML, XUL, および SVG)、要素のidは次のような要素の属性として指定することができます: <div id="table-cell2">.

However you can't use this attribute in a custom XML document without correctly specifying the type of the id attribute in the DOCTYPE. See getElementById Pitfalls for details.

Other common usages of id include using the element's ID as a selector when styling the document with CSS.

[編集] 仕様

DOM Level 2 HTML: id