全选、反选 不选

来源:互联网 发布:石家庄网站排名优化 编辑:程序博客网 时间:2024/03/29 09:30
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>全选/反选/不选</title><script type="text/javascript">window.onload=function(){        var ALL=document.getElementById('All');        var NOALL=document.getElementById('noAll');        var CHEBOX=document.getElementsByTagName('input');        ALL.onclick=function(){                for(var i=0;i<CHEBOX.length;i++){                        if(CHEBOX[i].checked==false ){                                CHEBOX[i].checked=true;                                }else{                                        CHEBOX[i].checked=false;                                        }                        }                }        NOALL.onclick=function(){                for(var i=0;i<CHEBOX.length;i++){                        CHEBOX[i].checked=false;                        }                }        }</script></head><body><button id="All">全选/反选</button><button id="noAll">取消</button><input type="checkbox" /><input type="checkbox" /><input type="checkbox" /><input type="checkbox" /><input type="checkbox" /><input type="checkbox" /><input type="checkbox" /><input type="checkbox" /></body></html>

0 0
原创粉丝点击