<div class="codetitle"> <span><a style="CURSOR: pointer" data="53855" class="copybut" id="copybut53855" onclick="doCopy('code53855')"><u>複製程式碼</u></a></span>如下碼:</div> <div class="codebody" id="code53855"> <br><span style="FONT-SIZE: 14px"> <br> <br> <br><title>元件處理.html</title> <br><meta http-equiv="keywords" content="keyword1,keyword2,keyword3">; <br><meta http-equiv="description" content="這是我的頁面"> <br><meta http-equiv="content-type" content="text/html; charset=UTF-8 "> <br><!--<link rel="stylesheet" type="text/css" href="./styles.css">--> <br>頭> <br> <br><input type="checkbox" id="checkItem">全選/全不選<br><br> <br><h3>嗜好</h3> <br><input type="checkbox" name="item">看書<br><br> <br><input type="checkbox" name="item">聽音樂<br><br> <br><input type="checkbox" name="item">打球<br><br> <br><input type="checkbox" name="item">散步<br><br> <br><input type="checkbox" name="item">寫入程式碼<br><br> <br> <br>window.onload = function(){ <br>var checkItem = document.getElementById("checkItem").onclick = function(){ <br>var itemsElement =var itemsElement = document.getElementsByName("item"); <br>for (var i = 0; i var itemElement = itemsElement[i]; <br>if (this.checked) { <br>itemElement.checked = "checked"; <br>} <br>else { <br>itemElement.checked = null; <br>} <br>} <br>} <br>} <br>} <br>} <br>} <br>} <br>) </span> </div>} } } } } ; 身體>