javascript代码实现全选
程序员文章站
2022-11-09 09:53:13
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>
下一篇: 四川南充营山特产?去了不吃那就太可惜了