javascript代码实现全选
程序员文章站
2022-05-10 10:44:25
javascript代码实现全选
javascript代码实现全选
<!doctype html> <html> <head> <meta charset="utf-8"> <title>按标签的类型返回</title> <script type="text/javascript"> function choiceall() { var obj=document.getelementsbytagname("input"); var call=document.getelementbyid("all"); var checked=call.checked; for(var i in obj) { if(obj[i].type = "checkbox") obj[i].checked = checked; } } </script> </head> <body> <p id="main"> <ul> <li> <input type="checkbox" /> <span>张三</span> </li> <li> <input type="checkbox" /> <span>李四</span> </li> <li> <input type="checkbox" /> <span>王五</span> </li> <li> <input type="checkbox" id="all" onclick="choiceall()"/> <span>全选</span> </li> </ul> </p> </body> </html>
上一篇: 自幼家境贫苦的刘裕,他为什么能建立刘宋?
下一篇: 最狠的兔子