高亮显示web页表格行的javascript代码

具体:http://www.verydemo.com/demo_c98_i59880.html

本篇作为开发学习笔记之一。
[文]
在web开发中经常遇到需要加亮鼠标指向的 表格行的情况。首先说说一般的情况。
・简单尝试
CSS2中允许我们对HTML元素使用hover伪类,这极大的方便了对于 表格的样式的控制。
我们从一个小例子开始:
XHTML(只列出了 表格部分,请自行补完页面,本例在Transational的DTD下通过):
代码如下:

<table class="datatable" cellspacing="0">
<thead>
<tr>
<th>Item</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr class="oddRow">
<td>项目Item1</td>
<td>值Value1</td>
</tr>
<tr class="evenRow">
<td>项目Item2</td>
<td>值Value2</td>
</tr>
<tr class="oddRow">
<td>项目Item3</td>
<td>值Value3</td>
</tr>
<tr class="evenRow">
<td>项目Item4</td>
<td>值Value4</td>
</tr>
<tr class="oddRow">
<td>项目Item5</td>
<td>值Value5</td>
</tr>
<tr class="evenRow">
<td>项目Item6</td>
<td>值Value6</td>
</tr>
</tbody>
</table>

然后用CSS定义了 表格的样式:
代码如下:

.datatable{
margin:15px auto;
width:500px; /*这两行可以根据需要修改,仅为示例*/
}
.datatable,.datatab…………………………………………………………………………

猜你喜欢

转载自huangxiaoshi8896513.iteye.com/blog/2072225