自身の属性の値を取得または設定します。Elementの属性を表すために使用されます。
- 構文
- String = Attr.value
- Attr.value = String
- 引数
- 戻り値
Attr オブジェクトを返すメソッド・プロパティ
- Document.value (DOM)
- 新しいAttrオブジェクトを生成して返します。
- Element.value (DOM)
- 指定された属性名に対応する属性ノードを取得します。
使い方
値を取得
<div id="content">This is sample text.</div>
DIM Document = IE.Document
DIM Elements = Document.getElementsByTagName("div")
DIM Element = Elements.Item(0)
DIM Attr = Element.getAttributeNode("id")
PRINT Attr.value
- 結果
content
値を設定
<div id="content">This is sample text.</div>
DIM Document = IE.Document
DIM Elements = Document.getElementsByTagName("div")
DIM Element = Elements.Item(0)
DIM Attr = Element.getAttributeNode("id")
Attr.value = "sample"
<div id="sample">This is sample text.</div>
プログラム実行例
要素に属性を追加する
結果
<div>
<h1 style="color: red;">Example Domain</h1>
<p>This domain is for use in illustrative examples in documents. You may use this
domain in literature without prior coordination or asking for permission.</p>
<p><a href="https://www.iana.org/domains/example">More information...</a></p>
</div>
使用関数
この記事は役に立ちましたか?
ご協力ありがとうございます。