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