JoJ*_*oJo 3 javascript reserved-words prototypejs
在HTML中,您可以指定label标签的"for"属性,以便在用户单击标签时选择相应的单选按钮:
<input type="radio" name="group" value="1" id="radioButtonId" />
<label for="radioButtonId">label text</label>
Run Code Online (Sandbox Code Playgroud)
使用javascript动态创建标签标签时存在问题(特别是使用Prototype JS框架).For是for循环的保留关键字.原型JS的文档显示,类名是保留的关键字码字类,但它没有说的码字什么的是.它是什么?
new Element(
'label', {
for: 'radioButtonId'
}
).update('label text');
Run Code Online (Sandbox Code Playgroud)
要将保留的工作用作对象文字中的键,只需将其包装在引号中,如下所示:
new Element(
'label', {
'for': 'radioButtonId'
}
).update('label text');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3029 次 |
| 最近记录: |