<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript" src="jquery-1.8.3.js"></script>
<script type="text/javascript">
$(function(){
$("input[type='button'][name='selectAll']").click(function(){
$("input[type='checkbox'][name='fruit']").each(function(){
$(this).attr("checked",true);
});
});
$("input[type='button'][name='disSelectAll']").click(function(){
$("input[type='checkbox'][name='fruit']").each(function(){
$(this).attr("checked",false);
});
});
$("input[type='button'][name='reverseSelect']").click(function(){
$("input[type='checkbox'][name='fruit']").each(function(){
$(this).attr("checked",!$(this).attr("checked"));
});
});
});
</script>
</head>
<body>
<form action="#">
<input type="checkbox" name="fruit" value="apple">apple
<input type="checkbox" name="fruit" value="orange">orange
<input type="checkbox" name="fruit" value="watermelon">watermelon
<input type="checkbox" name="fruit" value="strawberry">strawberry
<input type="button" name="selectAll" value="SelectAll">
<input type="button" name="disSelectAll" value="disSelectAll">
<input type="button" name="reverseSelect" value="reverseSelect">
</form>
</body>
</html>
jQuery_review之jQuery实现多选框的反选、全选、全不选,布布扣,bubuko.com
jQuery_review之jQuery实现多选框的反选、全选、全不选
原文:http://blog.csdn.net/ziwen00/article/details/38128475