<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
/**
* Select all checkbox
*/
flag = false;
$(".selectall").click(function() {
flag = !flag;
$("input[name='box[]']").each(function() {
$(this).attr("checked" , flag);
});
$(".selectall").attr("checked", flag);
});
});
</script>
<input type="checkbox" class="selectall"> Select All<br />
<input type="checkbox" name="box[]"><br />
<input type="checkbox" name="box[]"><br />
<input type="checkbox" name="box[]"><br />
<input type="checkbox" name="box[]"><br />
<input type="checkbox" name="box[]"><br />
<input type="checkbox" name="box[]"><br />
<input type="checkbox" name="box[]"><br />
<input type="checkbox" name="box[]"><br />
2010年12月9日 星期四
[jQuery] Select All Checkbox 選取所有選取框checkbox
Sample Below: (save to html to try this)