checkbox 全选/全不选 及选中取值
ie chrome都ok
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script> <title>Insert title here</title> <script type="text/javascript"> $(document).ready(function(){ //全选/全不选处理 $("#allChoice").click(function(){ $("input[name='choice']").attr("checked",this.checked); }); //获取已选checkbox值 $("#choose").click(function(){ $("input[name='choice']:checked").each(function() { console.log($(this).attr("id")); }); }); }); </script> </head> <body> <div> <input type="checkbox" id="allChoice">全选/全不选</input> <input type="checkbox" name="choice" id="one" value="first" value="one1">1</input> <input type="checkbox" name="choice" id="two" value="second" value="two2">2</input> <input type="checkbox" name="choice" id="three" value="third" value="three3">3</input> <button type="button" id="choose">获取已选checkbox值</button> </div> </body> </html>

浙公网安备 33010602011771号