时间:2021-07-01 10:21:17 帮助过:6人阅读
浅谈js中的in-for循环
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <script type="text/javascript" src="jquery.js"></script> </head> <body> <input type="checkbox" name="test" value="1"/><span>a</span> <input type="checkbox" name="test" value="2"/><span>b</span> <input type="checkbox" name="test" value="3"/><span>c</span> <input type="checkbox" name="test" value="4"/><span>d</span> <input type="checkbox" name="test" value="5"/><span>e</span><br> <input type='button' value='提交' onclick="fun()"/> <script> function fun(){ obj = document.getElementsByName("test"); check_val = []; //var k; for(k in obj){ if(obj[k].checked) check_val.push(obj[k].value); } alert(check_val); } </script> </body> </html>
以上就是小编为大家带来的浅谈js中的in-for循环全部内容了,希望大家多多支持脚本之家~