DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> 復選框全選與全不選操作實現思路
復選框全選與全不選操作實現思路
編輯:關於JavaScript     
復制代碼 代碼如下:
<SPAN style="FONT-SIZE: 14px"><!DOCTYPE html>
<html>
<head>
<title>復選框處理.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
<input type="checkbox" id="checkItem">全選/全不選
<br>
<h3>愛好</h3>
<input type="checkbox" name="item">看書
<br>
<input type="checkbox" name="item">聽音樂
<br>
<input type="checkbox" name="item">打球
<br>
<input type="checkbox" name="item">散步
<br>
<input type="checkbox" name="item">寫代碼
<br>
<script>
window.onload = function(){
var checkItem = document.getElementById("checkItem").onclick = function(){
var itemsElement = document.getElementsByName("item");
for (var i = 0; i < itemsElement.length; i++) {
var itemElement = itemsElement[i];
if (this.checked) {
itemElement.checked = "checked";
}
else {
itemElement.checked = null;
}
}
}
}
</script>
</body>
</html>
</SPAN>
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved