Attrアトリビュート.valueバリュー プロパティ

自身の属性の値を取得または設定します。Elementの属性を表すために使用されます。

構文
  1. String = Attr.value
  2. Attr.value = String
引数
戻り値

Attr オブジェクトを返すメソッド・プロパティ

Document.value (DOM)
新しいAttrオブジェクトを生成して返します。
Element.value (DOM)
指定された属性名に対応する属性ノードを取得します。

使い方

値を取得

HTML
<div id="content">This is sample text.</div>
UWSC
DIM Document = IE.Document
DIM Elements = Document.getElementsByTagName("div")
DIM Element = Elements.Item(0)
DIM Attr = Element.getAttributeNode("id")

PRINT Attr.value
結果
プレーンテキスト
content

値を設定

HTML
<div id="content">This is sample text.</div>
UWSC
DIM Document = IE.Document
DIM Elements = Document.getElementsByTagName("div")
DIM Element = Elements.Item(0)
DIM Attr = Element.getAttributeNode("id")

Attr.value = "sample"
HTML
<div id="sample">This is sample text.</div>

プログラム実行例

要素に属性を追加する

UWSC
結果
HTML
<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>
使用関数

この記事は役に立ちましたか?

はい
いいえ
ご協力ありがとうございます。