ラベルhtmlForプロパティ
例
ラベルのfor属性の値を返します。
var x = document.getElementById("myLabel").htmlFor;
定義と使用法
htmlForプロパティは、ラベルのfor属性の値を設定または返します。
for属性は、ラベルがバインドされるフォーム要素を指定します。
ブラウザのサポート
Property | |||||
---|---|---|---|---|---|
htmlFor | Yes | Yes | Yes | Yes | Yes |
構文
htmlForプロパティを返します。
labelObject.htmlFor
htmlForプロパティを設定します。
labelObject.htmlFor = id
プロパティ値
Value | Description |
---|---|
id | The id of the element the label is bound to |
技術的な詳細
戻り値: | ラベルがバインドされている要素のIDを表す文字列 |
---|
その他の例
例
ラベルのfor属性の値を変更します。
document.getElementById("myLabel").htmlFor = "newValue";
関連ページ
HTML参照:属性のHTML <label>
❮ラベルオブジェクト