Use the jQuery selector to enable line-changing and use javaScript to enable line-changing.

Source: Internet
Author: User

<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<! -- What is a selector?
The jQuery selector inherits some of the syntax of CSS and Path, allowing you to quickly and accurately select DOM elements by Tag Name, attribute name, or content without worrying about browser compatibility, you can use the jQuery selector to precisely locate page elements to complete element and behavior processing.
What are the advantages of selector?
Compared with the traditional JavaScript method to obtain page elements and portable foods, the jQuery selector has obvious advantages in the following two aspects:
* Simpler code
* Comprehensive Detection Mechanism
-->
<Title> </title>
<Script src = "jquery-1.9.1.js" type = "text/javascript"> </script>

 


<Style type = "text/css">
Body {font-size: 12px; text-align: center ;}
# TbStu {width: 260px; border: solid 1px #666; background-color: # eee}
# TbStu tr {line-height: 23px ;}
# TbStu tr th {background-color: # ccc; color: # fff}
# TbStu. trOdd {background-color: # fff}
</Style>
<! -- Use javaScript to change the color of the line -->
<! --
<Script type = "text/javascript">
Window. onload = function (){
Var oTb = document. getElementById ("tbStu ");
For (var I = 0; I <oTb. rows. length-1; I ++ ){
If (I % 2 ){
OTb. rows [I]. className = "trOdd ";
}
}
}
</Script>
-->


<! -- Use the jQuery selector to change the color of the line -->
<Script type = "text/javascript">
$ (Function (){
$ ('# TbStu tr: nth-child (even)'). addClass ('trodd ');
})
</Script>


</Head>
<Body>
<Table id = "tbStu" cellpadding = "0" cellspacing = "0">
<Tbody>
<Tr> <th> Student ID </th> <th> name </th> <th> gender </th> <th> total score </th> </tr>
<Tr> <td> 001 </td> <td> Zhang San </td> <td> male </td> <td> 100 </td> </tr>
<Tr> <td> 002 </td> <td> Li Si </td> <td> female </td> <td> 100 </td> </tr>
<Tr> <td> 003 </td> <td> Wang Wu </td> <td> 100 </td> </tr>
<Tr> <td> 004 </td> <td> Zhao liu</td> <td> female </td> <td> 100 </td> </tr>
<Tr> <td> 005 </td> <td> week 7 </td> <td> male </td> <td> 100 </td> </tr>
<Tr> <td> 006 </td> <td> wang ba </td> <td> female </td> <td> 100 </td> </tr>
</Tbody>
</Table>
</Body>
</Html>

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.