I have a several columns of :checkboxes and labels.
<ul class="column1">
<li>
<input value="jan" type="checkbox" />
<label>Jan</label>
</li>
<li>
<input value="feb" type="checkbox" />
<label>Feb</label>
</li>
<li> etc..<li>
</ul>
I have copied the val from the attribute value”” to the attribute id””
var tagCheckbox = ("ul li :checkbox");
$(tagCheckbox).attr("id", function() {
return "id_" + this.value;
});
Now I want to copy the val of the input value”” or id”” to the attribute for”” on the <label>
How can I do that?
.attr(,); wont do it alone, because it only grabs the first :checkbox and copy that same value to all labels
Try this: