Skip to content Skip to sidebar Skip to footer

Htmlfor Not Working

I created 3 radio buttons and a label for each of them using JavaScript. When I try adding for in the label using htmlFor, it doesn't apply it to the actual DOM Element. Meaning, w

Solution 1:

The htmlFor is used to bind a label to a specific form element. However, it uses the id of that form element (not the name).

Source MDN:

The HTMLLabelElement.htmlFor property reflects the value of the for content property. That means that this script-accessible property is used to set and read the value of the content property for, which is the ID of the label's associated control element.

Also, in your fiddle, you misspelled label.

Updated fiddle: https://jsfiddle.net/h09mm827/2/

Post a Comment for "Htmlfor Not Working"