javascript进阶篇9-4
<script type="text/javascript">
function checkall(){
var hobby = document.getElementsByTagName("input");
for(var i=0;i<hobby.length;i++){
if(hobby[i].type=="checkbox"){
hobby[i].checked=true;
}
}
}
function clearall(){
var hobby = document.getElementsByName("hobby");
for(var i=0;i<hobby.length;i++){
hobby[i].checked=false;}
/*这里为什么不能直接hobby.checked=false;而要通过for循环*/
}
function checkone(){
var j=document.getElementById("wb").value;
var hobby=document.getElementsByName("hobby");
hobby[parseInt(j)-1].checked=true;
}
</script>