标签:标题 htm cli body value click document checkbox elements
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <script> window.onload = function (){ var aInp = document.getElementsByTagName(‘input‘); // aInp[1].checked = false; // aInp[2].checked = true; aInp[0].onclick = function (){ for( var i=1; i<aInp.length; i++ ){ aInp[i].checked = !aInp[i].checked; /* if( aInp[i].checked ) { aInp[i].checked = false; } else { aInp[i].checked = true; } */ } }; }; </script> </head> <body> <input type="button" value="反选" /> <ul> <li><input type="checkbox" checked /></li> <li><input type="checkbox" /></li> <li><input type="checkbox" checked /></li> <li><input type="checkbox" /></li> <li><input type="checkbox" /></li> </ul> </body> </html>
标签:标题 htm cli body value click document checkbox elements
原文地址:http://www.cnblogs.com/lili-work/p/6286122.html