标签:
<</span>script> document.write("<</span>ul>"); for(var i=0;i<</span>18;i++){ document.write("<</span>li>"); document.write(‘<</span>input type="checkbox" value=‘+ i +‘/>888888888888888‘); document.write("<</span>/li>"); } document.write("<</span>/ul>"); document.write(‘<</span>label for="choose"><</span>input id="choose" type="checkbox" onclick="selectAll(this)">全选/全不选<</span>/label>‘); <</span>/script>
代码段2
<</span>script> var chks = document.getElementsByTagName("input"); function selectAll(obj){ for(i=0;i<</span>chks.length;i++){ chks[i].checked = obj.checked; // 如果不传递 this 对象,使用事件参数的 srcElement 属性获取数据源也是可以的 // chks[i].checked = event.srcElement.checked; } } <</span>/script>
标签:
原文地址:http://www.cnblogs.com/arxive/p/5928818.html