I don't know why the previous article has been in the review stage. Is there any word that is sensitive?
No matter what it is, re-writing this article will deepen your memory.
The first thing to do is to select all and all of the check box checkbox used for table data operations today. First, write the html language
<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>
I want to write a simple and clear way to achieve it after I search for it from the Internet. It is more than twice as good as I write.
Function changeAll () {var sall = document. getElementById ("sall"); // obtain the operation object var seach = document in the title bar. getElementsByName ("each"); // obtain the content bar object for (var I = 0; I <seach. length; I ++) {if (sall. checked) {seach [I]. checked = true;} else {seach [I]. checked = false ;}}}
It is much better to analyze its implementation method than to write it. At that time, I adopted two methods, but it is far less clear than the introduction of this model, it's a long time to use all your IDs for operations.
There are also common check boxes for operations on check boxes. In the above example, we will implement onchange = "change ()"
function change(){var seach=document.getElementsByName("each");for(var i=0;i<seach.length;i++){seach[i].checked=!seach[i].checked;}}
Finally, the most common check box is to get the information of a column to realize the value transfer. Here we get the following value:
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 insist on. If I write it again, the effect is actually not as good as the first time. No matter how much it is, come on, cainiao flying ....