<!DOCTYPE HTML><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Head> <Metaname= "Generator"content= "EditPlus" /> <title>To make a particular table interlaced</title> <Scriptsrc= "Jquery-1.7.1.min.js"type= "Text/javascript"></Script> <!--<script type= "Text/javascript" > (function () {alert ("functions have been called!) "); }) ();</script> - <!--idea: 1. Get the table based on the table ID. 2. Get the <tbody> element in the table. 3. Get <tr> elements under the <tbody> element. 4. Loop out the <tr> elements obtained. 5. Divide the index value of the <tr> element by 2 and modulo, and then set a different background color based on the parity. -</Head><Body> <TableID= "TB"> <tbody> <TR><TD>First line</TD><TD>First line</TD></TR> <TR><TD>Second line</TD><TD>Second line</TD></TR> <TR><TD>Third line</TD><TD>Third line</TD></TR> <TR><TD>Line Four</TD><TD>Line Four</TD></TR> <TR><TD>Line Five</TD><TD>Line Five</TD></TR> </tbody> </Table> <Scripttype= "Text/javascript"> //Traditional methods: //var item = document.getElementById ("TB");//Get an element with an ID of TB (table) //var tbody = item.getelementsbytagname ("tbody") [0];//Gets the first TBODY element of a table //var trs = Tbody.getelementsbytagname ("tr");//Get all the TR elements under the TBODY element //For (var i = 0; i < trs.length; i++)//cyclic TR element //{ //if (i% 2 = = 0)//modulo (take the remainder.) e.g. 0%2==0,1%2==1,2%2==0) // { //Trs[i].style.backgroundcolor = "#888"; Change the background color of the TR element that matches the condition // } //} //jquery Method: $('#tb tbody Tr:even'). CSS ("BackgroundColor", "#888"); //get the element with the ID of TB, then look for the tbody tag underneath it, and look for the TR element whose index value is even in tbody, changing its background color //css ("property", "value"), the style used to set the jquery object </Script></Body></HTML>