I do not know why the previous article has been in the audit phase. Is there a word that is sensitive to the crab?
No matter, once again wrote this, also is to deepen the memory.
The first thing to write is the full selection of the check box checkbox used in the table data operation today, and to write the following HTML language first
<table> <thead> <tr> <td><input type= "checkbox" id= "Sall" onchange= " Changeall () "></td> </tr> </thead> <tbody> <tr> <td> <input type= "checkbox" Name= "Each" value= "1" ></td> </tr> <tr> <td>< Input type= "checkbox" Name= "Each" value= "2" ></td> </tr> <tr> <td>< Input type= "checkbox" Name= "Each" value= "3" ></td> </tr> <tr> <td>< Input type= "checkbox" Name= "Each" value= "4" ></td> </tr> </tbody> </table >
to write a simpler and more straightforward way to do it after searching the web. It's more than one-fold .
function Changeall () {var Sall=document.getelementbyid ("Sall");//Gets the action object in the title bar var seach=document.getelementsbyname (" Each ");//Gets the object for the content bar for (Var i=0;i<seach.length;i++) {if (sall.checked) {seach[i].checked=true;} Else{seach[i].checked=false;}}}
to analyze the implementation of its method, than the decisive of their own writing is much better, their own at that time took the two methods, but far less than the simple introduction of this molding clear. Their full use ID to operate it is really smelly and long.
There are also more common check boxes for actions on check boxes. For the example above. Let's implement: Onchange= "Change ()"
function change () {var seach=document.getelementsbyname (' each '); for (Var i=0;i<seach.length;i++) {Seach[i]. checked=!seach[i].checked;}}
last. The most common use of a check box is to get the information for a column, which enables the value to be passed. Here we will get the following values:
var seach=document.getelementsbyname ("Each"), for (Var i=0;i<seach.length;i++) {if (seach[i].checked) {alert (seach [I].value];
}}
I don't know what I'm holding on to. It is not as good as the first time to write it again. No matter how much, come on, rookie fly fly ....
JS implementation check box operation-------Day41