<div class="codetitle"> <span><a style="CURSOR: pointer" data="4253" class="copybut" id="copybut4253" onclick="doCopy('code4253')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code4253"> <br><style type="text/css"> <BR>body { <BR>font-size:12px;text-align:center; <BR>} <BR>#tbStu { <BR>width:260px;border:1px solid #666;background-color:#eee; <BR>} <BR>#tbStu tr { <BR>line-height:23px; <BR>} <BR>#tbStu tr th { <BR>background-color:#ccc;color:#fff; <BR>} <BR>#tbStu .trOdd { <BR>background-color:#fff; <BR>} <BR></style> <br><script src="jQuery/jquery-1.9.1.js"></script> <br><script type="text/javascript"> <BR>//普通JS写法 <BR>//window.onload = function () { <BR>// var oTb = document.getElementById('tbStu'); <BR>// for (var i = 0; i < oTb.rows.length-1; i++) { <BR>// if (i % 2) <BR>// { <BR>// oTb.rows[i].className = "trOdd"; <BR>// } <BR>// } <BR>//} <BR>//jQuery选择器写法(选择table的行,隔一行,选择一行) <BR>$(function () { <BR>$('#tbStu tr:nth-child(even)').addClass("trOdd"); <BR>//jQuery给一个DIV复制内容时,不需要检测该DIV是否存在 <BR>// $('#divMain').html('这是一个检测页面'); <BR>}) <BR></script> <br> <br> <br><table id="tbStu" cellpadding="0" cellspacing="0"> <br><tbody> <br><tr> <br><th>学号</th> <th>姓名</th> <th>性别</th> <th>部分</th> <br> </tr> <br><tr> <br><td>1001</td> <td>张小明</td> <td>男</td> <td>320</td> <br> </tr> <br><tr> <br><td>1002</td> <td>李明琪</td> <td>女</td> <td>350</td> <br> </tr> <br><tr> <br><td>1003</td> <td>张三</td> <td>男</td> <td>150</td> <br> </tr> <br> </tbody> <br> </table> <br> <br> </div>