<div class="codetitle"> <span><a style="CURSOR: pointer" data="61120" class="copybut" id="copybut61120" onclick="doCopy('code61120')"><u>复代码</u></a></span> 代码如下:</div> <div class="codebody" id="code61120"> <br><!doctype html> <br><html> <br><머리> <br><meta charset="utf-8"> <br><title>jquery 테스트</title> <br><script src="jquery-1.11.1.min.js"></script> <br></head> <br><br><본문> <br><input type="checkbox" name="check" value="one"/>one<br/> <br><input type="checkbox" name="check" value="two"/>two<br/> <br><input type="checkbox" name="check" value="3"/>3<br/> <br><input type="checkbox" name="check" value="four"/>four<br/> <br><input type="checkbox" name="check" value="five"/>five<br/> <br><input type="checkbox" name="check" value="six"/>six<br/> <br><input type="checkbox" name="check" value="seven"/>seven<br/> <br><button name="sub">提交</button> <br><script type="text/javascript"> <br>$("button[name=sub]").click(function(){ <br>var len = $("input:checkbox:checked").length; <br>alert("你一共选中了" len "个复选框"); <br>}) <br></script> <br></body> <br></html> <br> </div> <br>이용할 수 있는 용도는 다음과 같습니다. 。 <br><br>유무한 시간 ,我们还对用户勾选复选框的个数做了限限房,假设只能勾选三个,应的代码是这样的: <br><div class="codetitle"><span><a style="CURSOR: pointer" data="52834" class="copybut" id="copybut52834" onclick="doCopy('code52834')">复제대码<u></u></a> 代码如下:</span></div> <div class="codebody" id="code52834"><!doctype html> <br><html> <br><머리> <br><meta charset="utf-8"> <br><title>jquery 테스트</title> <br><script src="jquery-1.11.1.min.js"></script> <br></head> <br><br><본문> <br><input type="checkbox" name="check" value="one"/>one<br/> <br><input type="checkbox" name="check" value="two"/>two<br/> <br><input type="checkbox" name="check" value="3"/>3<br/> <br><input type="checkbox" name="check" value="four"/>four<br/> <br><input type="checkbox" name="check" value="five"/>five<br/> <br><input type="checkbox" name="check" value="six"/>six<br/> <br><input type="checkbox" name="check" value="seven"/>seven<br/> <br><script type="text/javascript"> <br>$("input:checkbox").click(function(){ <br>var len = $("input:checkbox:checked").length; <br>if(len>3){ <br> Alert('亲,最多只能选三个哟~'); <br>return false; //另刚才勾选的取消 <br>} <br>}) <br></script> <br></body> <br></html> <br><br> </div>