I select some element with .someClass
and I want to select next <label>
element which occurs lower in the DOM tree.
Between those two elements can be anything else, e.g:
<input class="someClass" />
<p>asdfasdf</p>
<div></div>
<table>
<tr>
<td>
<label>SOMETHING</label>
</td>
</tr>
</table>
My script:
$(".question").each(function (index, value) {
vargroupNumber = ++index;
$(":radio", this)
.attr("name", "group" + groupNumber)
.each(function (index, value) {
$(this)
.removeAttr('checked')
.attr("id", "id" + groupNumber + index)
.next('label')
.attr("for", "id" + groupNumber + index);
});
});
I want to select and set something to this <label>
.