选择Jquery.each
是否可以选择从每个div中选择第一个无线电
<div>
<table class="sortable accountTable float_left">
<tr>
<td class="textlmiddle"><input type="radio" value="" rel=
".structure_group1" checked='checked' /></td>
<td>Organisation structure 1</td>
</tr>
<tr>
<td class="textlmiddle"><input type="radio" value="" rel=
".structure_group2" /></td>
<td>Organisation structure 2</td>
</tr>
<tr>
<td class="textlmiddle"><input type="radio" value="" rel=
".structure_group3" /></td>
<td>Organisation structure 3</td>
</tr>
<tr>
<td class="textlmiddle"><input type="radio" value="" rel=
".structure_group4" /></td>
<td>Organisation structure 4</td>
</tr>
</table>
</div>
<div>
<table class="sortable accountTable float_left">
<tr>
<td class="textlmiddle"><input type="radio" value="" rel=
".structure_group1" checked='checked' /></td>
<td>Organisation structure 1</td>
</tr>
<tr>
<td class="textlmiddle"><input type="radio" value="" rel=
".structure_group2" /></td>
<td>Organisation structure 2</td>
</tr>
<tr>
<td class="textlmiddle"><input type="radio" value="" rel=
".structure_group3" /></td>
<td>Organisation structure 3</td>
</tr>
<tr>
<td class="textlmiddle"><input name="acc_number2" type="radio" value="" rel=
".structure_group4" /></td>
<td>Organisation structure 4</td>
</tr>
</table>
</div>
<div>
<table class="sortable accountTable float_left">
<tr>
<td class="textlmiddle"><input type="radio" value="" rel=
".structure_group1" checked='checked' /></td>
<td>Organisation structure 1</td>
</tr>
<tr>
<td class="textlmiddle"><input type="radio" value="" rel=
".structure_group2" /></td>
<td>Organisation structure 2</td>
</tr>
<tr>
<td class="textlmiddle"><input type="radio" value="" rel=
".structure_group3" /></td>
<td>Organisation structure 3</td>
</tr>
<tr>
<td class="textlmiddle"><input name="acc_number2" type="radio" value="" rel=
".structure_group4" /></td>
<td>Organisation structure 4</td>
</tr>
</table>
</div>
这是DEMO
答案 0 :(得分:6)
我相信这会奏效:
$('body > div').each(function() {
$('input[type="radio"]', this).first().prop('checked', true);
});