我需要突出显示鼠标移过来的表格行。似乎是一件容易的事情,对吧?尤其是使用jQuery。但是,唉,我没那么幸运。jQuery高亮表格行
我为突出表行测试不同的解决方案,但没有什么似乎工作:-(
我已经测试了以下脚本:
// TEST one
jQuery(document).ready(function() {
jQuery("#storeListTable tr").mouseover(function() {
$(this).parents('#storeListTable tr').toggleClass("highlight");
alert('test'); // Just to test the mouseover event works
});
});
//TEST 2
jQuery(document).ready(function() {
$("#storeListTable tbody tr").hover(
function() { // mouseover
$(this).addClass('highlight');
},
function() { // mouseout
$(this).removeClass('highlight');
}
);
});
这是我的HTML代码
<html>
<head>
<title>Title</title>
<link rel="stylesheet" href="css/storeLocator.css" type="text/css"
media="screen" charset="utf-8" />
<script type="text/javascript" src="js/jquery.js" charset="utf-8"></
script>
</head>
<body>
<table id="storeListTable">
<thead>
<tr class="even">
<th>ID</th>
<th>Navn</th>
<th>E-post</th>
<th>Nettside</th>
</tr>
</thead>
<tbody>
<tr class="" id="store1">
<td>10</td>
<td>Boss Store Oslo</td>
<td> <a href="mailto:">E-post</a></td>
<td> <a href="#">www</a></td>
</tr>
<tr class="" id="store3">
<td>8</td>
<td>Brandstad Oslo City</td>
<td> <a href="mailto:[email protected]">E-post</a></td>
<td> <a href="#">www</a></td>
</tr>
<tr class="even" id="store4">
<td>7</td>
<td>Fashion Partner AS</td>
<td> <a href="mailto:[email protected]">E-post</a></td>
<td> <a href="#">www</a></td>
</tr>
<tr class="" id="store5">
<td>1</td>
<td>Follestad</td>
<td> <a href="mailto:[email protected]">E-post</a></td>
<td> <a href="#">www</a></td>
</tr>
<tr class="even" id="store6">
<td>2</td>
<td>Follestad</td>
<td> <a href="mailto:[email protected]">E-post</a></td>
<td> <a href="#">www</a></td>
</tr>
</tbody>
</table>
</body>
</html>
那么....谁能给我一个正确的方向?
UPDATE
我不使用jQuery任何更加突显表行,但CSS。
这是列表中的元素,但我猜这会为表行以及工作:
李:第n个孩子(奇){背景颜色:#f3f3f3; }
谢谢队友。 这就是我最终使用的插件。 – Steven 2009-05-13 22:54:19
作品,但旧的。使用Julian的方法背景色方法。注意 - 即现在大约是1.5%(和缩小) - 移动大约是7%(并且越来越多 - 所以哪一个专注于前进很容易:) – 2011-11-13 15:44:24