In HTML, you can assign the “for” attribute of a label tag so that when the user clicks the label, it selects the corresponding radio button:
<input type="radio" name="group" value="1" id="radioButtonId" />
<label for="radioButtonId">label text</label>
There’s problems when creating the label tag dynamically with javascript (specifically with Prototype JS framework). For is a reserved keyword for for loops. Prototype JS’s documentation shows that className is the code word for the reserved keyword class, but it doesn’t say what the code word for for is. What is it?
new Element(
'label', {
for: 'radioButtonId'
}
).update('label text');
classNameis the standard DOM property corresponding to theclassattribute; it’s nothing to do with Prototype per se.Similarly, the DOM property corresponding to the
forattribute ishtmlFor.