2
我试图显示在每个div中选中复选框的数量,但不知道如何选择span
。这与其他选择器
This $("input[@type=checkbox]:checked",this).length
works fine,I've put it in alert and number is correct,但我不知道如何为每个div选择#skills div h3 span
。
HTML
<td id="skills" colspan="2">
<div id="skills_0">
<h3>IT<span></span></h3>
<input type="checkbox" name=".." id=".." val=".." /> <label for="..">..</label>
...<!-- more inputs -->
</div>
...<!-- more divs -->
</td>
的jQuery:
$(document).ready(function() {
$('#skills div').each(function() {
$("h3 span",this).html($("input[@type=checkbox]:checked",this).length);
});
});
这不适合我 – miszczu 2012-08-10 08:51:14
工作,你对jsfiddle.net演示让我更清楚地知道错误。 – Fredy 2012-08-10 08:53:31
它在这里:http://jsfiddle.net/VQutV/ – miszczu 2012-08-10 08:59:54