标签:style blog class code java ext
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style type="text/css"> </style> </head> <body> <label id="btn"><input type="checkbox" /> 全选</label><br /> <input type="checkbox"/><br /> <input type="checkbox"/><br /> <input type="checkbox"/><br /> <input type="checkbox"/><br /> <input type="checkbox"/><br /> <input type="checkbox"/><br /> </body> <script type="text/javascript"> var oBtn = document.getElementById("btn"); var oInput = document.getElementsByTagName("input"); oBtn.onclick=function(){ for(var x = 0;x<oInput.length;x++){ oInput[x].checked=true; } }; </script> </html>
获取第一个input,并在该input中绑定点击事件,当点击该input时,通过for循环实现下面所有input全部选中
标签:style blog class code java ext
原文地址:http://www.cnblogs.com/LO-ME/p/3721854.html