<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="css/all.css" />
</head>
<body>
<label for="all">全選</label>
<input type="radio" name="check" id="all" value="" onclick="chec();"/>
<label for="only">反選</label>
<input type="radio" name="check" id="only"value="" onclick="nochec();"/><br />
<input type="checkbox" name="" id="" value="" />
<input type="checkbox" name="" id="" value="" />//可複製多個
</body>
<script type="text/javascript">javascript
//全選和反選在點擊時讓其checked爲true
var inp = document.getElementsByTagName("input");
function chec(){//全選狀態
for(var i =2;i < inp.length;i++){
inp[i].checked = true;
}
}
function nochec(){//反選
for(var i =2;i < inp.length;i++){
inp[i].checked = false;
}
}
</script>
</html>
css