Use JS to achieve full, inverse selection, all-in-all function (check)

Source: Internet
Author: User

<! DOCTYPE html>
<meta charset= "Utf-8"/>
<title></title>
<script type= "Text/javascript" >
Window.onload=function () {
Select All/Select All
var Chk1=document.getelementbyid ("Chk1");
Inverse selection
var Chk2=document.getelementbyid ("Chk2");
Get all the input tags
var Odiv=document.getelementbyid ("Chk");
var chks=odiv.getelementsbytagname ("input");
Chk1.onclick=function () {
Alert ("haha");
for (Var i=0;i<chks.length;i++) {
chks[i].checked=chk1.checked; Select All or select All
}
};
Chk2.onclick=function () {
for (Var i=0;i<chks.length;i++) {
chks[i].checked=!chks[i].checked;//Reverse Election
}
};
};
</script>
<body>
<div id= "Top" >

</div><div id="container">    <input type="checkBox" id="chk1">全选/全不选    <input type="checkBox" id="chk2">反选    

</body>

Use JS to achieve full, inverse selection, all-in-all function (check)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.