Posted in Javascript onNovember 28, 2013
效果:
代码:
<head runat="server"> <title></title> <script type="text/javascript"> window.onload = function () { var ckall = document.getElementById('ck1'); var ck = document.getElementsByName('name1'); ckall.onclick = function () { for (var i = 0; i < ck.length; i++) { if (ckall.checked == true) { ck[i].checked = true; } else { ck[i].checked = false; } } } }; </script> </head> <body> <form id="form1" runat="server"> <input type="checkbox" id="ck1" /> 全选 <div id="div1"> <input type="checkbox" name="name1" /> <input type="checkbox" name="name1" /> <input type="checkbox" name="name1" /> <input type="checkbox" name="name1" /> <input type="checkbox" name="name1" /> <input type="checkbox" name="name1" /> </div> </form> </body>
JS小功能(checkbox实现全选和全取消)实例代码
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@