1. Table odd and even rows
1<! DOCTYPE HTML Public"-//W3C//DTD XHTML 1.0 transitional//en" "HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-TRANSITIONAL.DTD">2"http://www.w3.org/1999/xhtml">34<title></title>5<meta http-equiv="Content-type"Content="text/html; Charset=utf-8"/>6<script type="Text/javascript">7Window.onload = function () {//page all elements loaded complete8 varItem = document.getElementById ("TB");//get an element with an ID of TB (table)9 varTbody = Item.getelementsbytagname ("tbody")[0];//gets the first TBODY element of a tableTen varTRS = Tbody.getelementsbytagname ("TR");//gets all the TR elements under the TBODY element One for(varI=0; i < trs.length;i++) {//Cyclic TR element A if(i%2==0){//Take the mold. (Take the remainder. such as 0%2=0, 1%2=1, 2%2=0, 3%2=1) -Trs[i].style.backgroundcolor ="#888";//changes the background color of the TR element that matches the condition. - } the } - } -</script> - +<body> -<table id="TB"> +<tbody> A<tr><td> first line </td><td> first row </td></tr> at<tr><td> second row </td><td> second row </td></tr> -<tr><td> third row </td><td> third row </td></tr> -<tr><td> Line Fourth </td><td> line fourth </td></tr> -<tr><td> Line Fifth </td><td> line fifth </td></tr> -<tr><td> Line Sixth </td><td> line sixth </td></tr> -</tbody> in</table> -</body> to2. CheckBox
1<! DOCTYPE HTML Public"-//W3C//DTD XHTML 1.0 transitional//en" "HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-TRANSITIONAL.DTD">2"http://www.w3.org/1999/xhtml">34<title></title>5<meta http-equiv="Content-type"Content="text/html; Charset=utf-8"/>6<script type="Text/javascript">7Window.onload = function () {//page all elements loaded complete8 varBTN = document.getElementById ("btn");//get the element with ID btn (button)9Btn.onclick = function () {//to add an onclick event to an elementTen vararrays =NewArray ();//Create an Array object One varItems = Document.getelementsbyname ("Check");//gets a set of elements named Check (checkbox) A for(i=0; i < items.length; i++) {//Loop This set of data - if(Items[i].checked){//decide whether to select -Arrays.push (Items[i].value);//add eligible additions to the array. push () is a method in a JavaScript array . the } - } -Alert"the number of checks is:"+arrays.length); - } + } -</script> + A<body> at<form method="Post"action="#"> -<input type="checkbox"Value="1"Name="Check" checked="checked"/> -<input type="checkbox"Value="2"Name="Check"/> -<input type="checkbox"Value="3"Name="Check" checked="checked"/> -<input type="Button"Value="the number you selected"Id="btn"/> -</form> in</body> -Sharp jquery (Table,checkbox)