jquery全选反选
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="Content-Type" content="text/html; charset=gbk" /> <title>test</title> </head> <script type="text/javascript" src="jquery.js?2015"></script> <!--不能用<script src="jquery.js"/>,必须<script></script> --> <script type="text/javascript" language="javascript"> $(document).ready(function(){ $("#selectAllorNone").click(function(){ //alert('run'); $("#checkList :checkbox").each(function(){ //alert('run'); $(this).attr("checked",!$(this).attr("checked")); }); }); }); </script> <body> <div id="checkList"> <input type="checkbox">心</input> <input type="checkbox">想</input> <input type="checkbox">事</input> <input type="checkbox">成</input> </div> <input type="button" value="全选/全不选" id="selectAllorNone"> <input> </body> </html>