<div class="codetitle"> <span><a style="CURSOR: pointer" data="23948" class="copybut" id="copybut23948" onclick="doCopy('code23948')"><u>複製代碼</u></a></span> 代碼如下:</div> <div class="codebody" id="code23948"> <br><input type="checkbox" id="checkAll" value=" 1">全選/全部不選<br><input type="checkbox" name="items" value="1">1 <br><input type="checkbox" name="items" value="2 ">2 <br><input type="checkbox" name="items" value="3">3 <br><input type="checkbox" name="items" value="4">4 <br> <input type="checkbox" name="items" value="5"> <br><input type="button" onclick="show()" value="提示選擇的"> <br><script> <BR>$("#chekcAll").click(function(){ <BR>if(this.checked){ <BR>$("input[name=items]").attr("checked","checked" ); <BR>} <BR>else{ <BR>$("input[name=items]").attr("checked",null); <BR>} <BR>}) <BR>function show( ){ <BR>var strIds=new Array();//宣告一個存放id的陣列<BR>$("input[name=items]").each(function (i,d){ <BR>if ( d.checked) { <BR>strIds.push(d.value); <BR>} <BR>}) <BR>if(strIds.length<1) <BR>alert("您沒有選取項目!") ; <BR>else{ <BR>var ids=strIds.join(","); <BR>alert("你選取的字串有:" ids); <BR>} <br><br><BR>} <br><br></script> <br> </div>