<div class="codetitle"> <span><a style="CURSOR: pointer" data="89516" class="copybut" id="copybut89516" onclick="doCopy('code89516')"><u>複製代碼</u></a></span>如下代碼:</div> <div class="codebody" id="code89516"> <br>渡//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br> <br> <br><meta http-equiv="Content-Type" content="text/html; charset=utf-8">> <br> <br> <br>$(document).ready(function(){ <br>$("#selectAll" ).click(function(){ <br>//這裡也可以直接用this,打破js語句<br>if ($(this)[0].checked){ <br>$('[name=items] :checkbox').attr("checked",true); <br>}else{ <br>$('[ name=items]:checkbox').attr("已選取",false); <br>$ ("#XOR").click(function(){ <br>$( "[name=items]:checkbox").each(function(){ <br>this.checked=!this.checked; <br> }) <br>}); <br>腳本> <br><title>無標題文件</title> <br>頭> <br> <br><input type="checkbox " name="items" value="足球">足球<br><input type="checkbox" name="items" value="足球">足球<br><input type="checkbox" name=" items" value="足球">足球<br><input type="checkbox" name="items" value="足球">足球<br><input type="checkbox" id="selectAll" value="全選/不選">全選/全部選<br><input type="button" id="XOR" value> <br>身體> <br> <br><br> </div>