JS implementation check box selection, full selection and inverse selection

Source: Internet
Author: User

1<! DOCTYPE html>234<meta charset= "UTF-8" >5<title>checkbox</title>6<style type= "Text/css" >7 . main{8 width:400px;9 height:400px;Ten margin:20px Auto; One         } A li{ -list-Style:none; -text-shadow:5px 5px 3px Rgba (53,56,41,0.5); the             } - h3{ -text-Align:center; -text-shadow:5px 5px 3px Rgba (53,56,41,0.5); + Color:blue; -             } + . boxs,.choice{ A position:relative; at left:100px; -             } -</style> -  - -<body> in          -<div class=main> to +<div class= "Boxs" > -<ul> the<li><input type= "checkbox"/> Macy's </li> *<li><input type= "checkbox"/> Neymar </li> $<li><input type= "checkbox"/> Suarez </li>Panax Notoginseng<li><input type= "checkbox"/> Illesta </li> -<li><input type= "checkbox"/> Roberto </li> the<li><input type= "checkbox"/> Lakitic </li> +</ul> A</div> the<div class= "Choice" > +<button onclick= "SELECT (1)" > select all </button> -<button onclick= "SELECT (2)" > select all </button> $<button onclick= "SELECT (3)" > Reverse </button> $</div> -</div> -          the<script> -         functionSelect (num)Wuyi         { the             varItems = document.getelementsbytagname (' input ') -              for(vari=0; i<items.length; i++) Wu             {    -             Switch(num) About                 { $                  Case1:items[i].checked =true; Break; -                  Case2:items[i].checked =false; Break; -                  Case3:items[i].checked=!items[i].checked; Break; -  A                 }               the             }                           -     } $</script> the</body> the

JS implementation check box selection, full selection and inverse selection

Related Article

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.