8月 2 2015 js全选/全不选 js全选/全不选 js 方法一:12345678910111213141516171819202122232425<!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><title>全选/全不选1</title><script src="http://libs.baidu.com/jquery/1.8.3/jquery.min.js"></script></head><body> <input type="checkbox" class="allcheck">全选/全不选<br> <input type="checkbox" class="subcheck"> <input type="checkbox" class="subcheck"> <input type="checkbox" class="subcheck"> <input type="checkbox" class="subcheck"> <input type="checkbox" class="subcheck"> <script> $(function(){ $(".allcheck").click(function(){ $(".subcheck").prop("checked",$(".allcheck").prop("checked")); }); }); </script></body></html> 方法二: 1234567891011121314151617181920212223242526272829303132333435<!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><title>全选/全不选、反选2</title><script src="http://libs.baidu.com/jquery/1.8.3/jquery.min.js"></script></head><body> <input type="checkbox" class="allcheck">全选/全不选 <input type="checkbox" class="allcheck">反选<br><br> <input type="checkbox" class="subcheck"> <input type="checkbox" class="subcheck"> <input type="checkbox" class="subcheck"> <input type="checkbox" class="subcheck"> <input type="checkbox" class="subcheck"> <script> $(function(){ //全选/全不选 $(".allcheck").on("change",function(){ $(".subcheck").prop("checked",this.checked); $(".backcheck").prop("checked",false); }); //反选 $(".backcheck").on("change",function(){ $(".subcheck").each(function(i,cur){ cur.checked=!cur.checked; }); $(".allcheck").prop("checked",false); }); }); </script></body></html> < 让超大banner图片不拉伸、全屏宽、居中显示的方法 document.ready=function(){}和$(function(){})和window.onload=function(){}区别 >