How do you set the for attribute of an HTML <label> element in JavaScript without using jQuery or any other library?
for
<label>
Use the htmlFor attribute. I assume it has a slightly critical name because for is a keyword in JavaScript:
htmlFor
var label = document.createElement('label'); label.htmlFor = 'some-input-id';