jquery checkBox的相关操作——全选、反选、获得所有选中的checkBox
1、全选
Box" ]").attr("checked","true");="" })="" <="" pre="">
2、取消全选(全不选)
Box" ]").removeattr("checked");="" })="" <="" pre="">
3、选中所有奇数
Box" ]:odd").attr("checked","true");="" })="" <="" pre="">
4、选中所有偶数
Box" ]:even").attr("checked","true");="" })="" <="" pre="">
5、反选
Box" ]").each(function(){="" if($(this).attr("checked"))="" {="" $(this).removeattr("checked");="" }="" else="" $(this).attr("checked","true");="" })="" <="" pre="">
或者
Box").each(function(i,o){
$(o).attr("checked",!$(o).attr("checked"));
});
});
6、获取选择项的值
7、遍历选中项
Box][checked]").each(function(){
//由于复选框一般选中的是多个,所以可以循环输出
alert($(this).val());
});
8、例子
无标题页