19. JavaScript Basics

Source: Internet
Author: User

1, a few days received a wonderful demand, that is, when the mouse wheel sliding, div to hover, so this caused my knowledge of JavaScript review

First start with the type of the most basic variable

<! DOCTYPE html>    null); </script>

The above alert will show true

2, select all, all do not select and anti-select feel personal really is not on the code has to rely on, feel if can not knock the code is really good grade, so in the future want to go home to help mom buy goods, feel can

It's better to earn money by mouth than to be strong.

<! DOCTYPE html>Football<input type= "checkbox" name= "items" value= "basketball" >Basketball<input type= "checkbox" name= "Items" value= "Volleyball" >Volleyball<input type= "checkbox" name= "Items" value= "Tan Yu" >Tan Yu<br/> <input type= "button" id= "Checkall" value= "Select All" > <input type= "button" id= "Nocheckall" value= "All not selected "> <input type=" button "id=" Oppositeall "value=" reverse select "> <script type=" Text/javascript ">varCheckbutton = document.getElementById ("Checkall"); Checkbutton.onclick=function() {            varItems = Document.getelementsbyname ("Items");  for(vari = 0; i < items.length; i++) {                if(!items[i].checked) {items[i].checked=true; }            }        }        varNocheckbutton = document.getElementById ("Nocheckall"); Nocheckbutton.onclick=function() {            varITEMS2 = Document.getelementsbyname ("Items");  for(vari = 0; i < items2.length; i++) {                if(items2[i].checked) {items2[i].checked=false; }            }        }        varOppcheckbutton = document.getElementById ("Oppositeall"); Oppcheckbutton.onclick=function() {            varITEMS3 = Document.getelementsbyname ("Items");  for(vari = 0; i < items3.length; i++) {                if(items3[i].checked) {items3[i].checked=false; } Else{items3[i].checked=true; }            }        }    </script></body>

3. Click Close, click Open

<! DOCTYPE html>div {display:none;} A {background-Color:orange;}. Open {Display:block;}. Close {display:none;}    p{Font:bolder; Font-family:cursive; Font-Style:italic;    Color:blue; Background-Color:orange;} Table, TR, TD {padding:0px;}</style><script type= "Text/javascript" >functionOpendiv (a) {varCurrentdiv = A.parentnode.getelementsbytagname ("div") [0]; varDIVs = document.getElementsByTagName ("div");  for(vari = 0; i < divs.length; i++) {            if(Currentdiv = =Divs[i]) {Currentdiv.classname= "Open"; } Else{divs[i].classname= "Close"; }        }    }</script>

The results of the code run are as follows

19. JavaScript Basics

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.