Select and change the TR color JavaScript Implementation code _ Typical effects

Source: Internet
Author: User
<ptml> <pead> <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "> <title> Web Effects Select all and change tr color </title> <script language=" JavaScript "type=" text/ JavaScript "for=" checkbox "event=" onclick "> Tr_bgcolor (this); </script> <script language= "JavaScript" type= "Text/javascript" > <!--function Tr_bgcolor (c) {var tr = C.parentnode.parentnode; Tr.rowindex% 2 = 0? Tr.style.backgroundColor = c.checked? ' #add6a6 ': ' #eee ': Tr.style.backgroundColor = c.checked? ' #add6d6 ': '; function Selall (obj) {for (var i=0 i<obj.form.elements.length; i++) if (obj.form.elements[i].type = ' che Ckbox ' && obj.form.elements[i]!= obj) {obj.form.elements[i].checked = obj.checked; Tr_bgcolor (Obj.form.elements[i]); }//--> </script> </pead> <body> <form id= "Form1" Name= "Form1" method= "Post" action= "" > <table width= "border=" 0 "align=" Center "cellpadding= "0" cellspacing= "1" bgcolor= "#888888" > <tr><td><input name= "selectall" type= "checkbox" Value= "onclick=" Selall (this)/></td></tr> <tr><td> <table width= "100%" border= "0" cellpadding= "0" cellspacing= "0" bgcolor= "#FFFFFF" > <tr ><td width= "6%" ><input type= "checkbox" Name = "checkbox"/></td><td width= "94%" >***********************</td></tr> <tr><td ><input type= "checkbox" name= "checkbox"/></td><td>***********************</td></tr > <tr ><td><input type= "checkbox" name= "checkbox"/></td><td>********************* **</td></tr> <tr><td><input type= "checkbox" name= "checkbox"/></td><td>* </td></tr> <tr ><td><input type= "checkbox" name= "checkbox"/>& Lt;/td><td>***********************</td></tr> <tr><td><input type= "checkbox" name= "checkbox"/></td><td>************** </td></tr> <tr ><td><input type= "checkbox" name= "checkbox"/></td>< td>***********************</td></tr> <tr><td><input type= "checkbox" Name= "checkbox" /></td><td>***********************</td></tr> <tr ><td><input type= " CheckBox "Name=" checkbox "/></td><td>***********************</td></tr> </table> & lt;/td></tr> </table> </form> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]


<script language= "JavaScript" event= "onclick" for= "checkbox" type= "Text/javascript" > Tr_bgcolor (this); </script> <script language= "JavaScript" type= "Text/javascript" > <!--function Tr_bgcolor (c) {var tr = c . Parentnode.parentnode; Tr.rowindex% 2 = 0? Tr.style.backgroundColor = c.checked? ' #FFCC99 ': ' #eee ': Tr.style.backgroundColor = c.checked? ' #FFCC99 ': '; function Doselect (obj) {for (var i=0 i<obj.form.elements.length; i++) {if (Obj.form.elements[i].type = = ' checkbox ' && obj.form.elements[i]!= obj) {obj.form.elements[i].checked = obj.checked; Tr_bgcolor (Obj.form.elements[i]); }}//--> </script> <form id= "Form1" Name= "Form1" action= "" method= "post" > <table cellspacing= "1 "cellpadding=" 1 "width=" align= "center" bgcolor= "#888888" border= "0" > <tr> <td> <input onclick= " Doselect (This) "Type=" checkbox "value=" All "Name=" Sel_box "id=" Sel_box "/><label for=" Sel_box "> select all </label></td> </tr> <tr> <td> <table cellspacing= "1" cellpadding= "5" width= "100%" bgcolor= " #ffffff "border=" 0 "> <tr > <td width=" 6% "><input type=" checkbox "name=" checkbox "/></td> TD width= "94%" > Content content Contents content </td> </tr> <tr> <td><input type= "checkbox" Name= " CheckBox "/></td> <td> content content contents content </td> </tr> <tr > <td><input type=" chec Kbox "name= checkbox"/></td> <td> content content content </td> </tr> <tr> <td>< Input type= "checkbox" name= "checkbox"/></td> <td> content content content </td> </tr> <tr > ; Td><input type= "checkbox" name= "checkbox"/></td> <td> content Content content contents </td> </tr> <tr> <td><input type= ' checkbox ' name= ' checkbox '/></td> <td> content content content content </td> </tr> <tr > <td><input type= "checkbox" name= "checkbox"/></td> <td> content content content </td> </tr> <tr> <td> <input type= "checkbox" name= "checkbox"/></td> <td> content content content </td> </tr> <tr > <td><input type= "checkbox" name= "checkbox"/></td> <td> content content content </td> </ tr> </table> </td> </tr> </table> </form>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
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.