我试图让它在选择一行时改变颜色/背景,就像我将它设置为悬停时一样,并且能够取消选择该行......
如果您查看: http: //jsfiddle.net/q7ApN/,您可以看到它在悬停时应该是什么样子......
如果改变:
#gradient-style tbody tr:hover td {
background: #d0dafd url('table-images/gradhover.png') repeat-x;
color: #339;
}
至
#gradient-style tbody tr:hover, tr.selected td {
background: #d0dafd url('table-images/gradhover.png') repeat-x;
color: #339;
}
实际 HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
<style type="text/css">
<!--
@import url("nstyle.css");
-->
</style>
</head>
<body>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
$("tr").click(function(){
$(this).addClass("selected").siblings().removeClass("selected");
});
</script>
<div id="header_container">
<div id="header">
<a href="http://test.com/" target="_blank">test</a>
</div>
</div>
<div id="container">
<table id="gradient-style" summary="">
<tbody>
<thead>
<tr>
<th scope="col">title</th>
<th scope="col">title</th>
<th scope="col">title</th>
<th scope="col">title</th>
</tr>
</thead>
<tr><td>data</td><td class="test">data</td><td class="test">data</td></tr>
<tr><td>data</td><td>data</td><td class="test">data</td></tr>
<tr><td class="test">data</td><td class="test">data</td><td class="test">data</td></tr>
<tr><td class="test">data</td><td class="test">data</td><td class="test">data</td></tr>
</tbody>
<tfoot>
<tr>
<td colspan=34><em>testing box :)</em></td>
</tr>
</tfoot>
</table>
</div>
<div id="footer_container">
<div id="footer">
<a href="http://test.com/" target="_blank">test</a>
<div id="footer1">
<i>test.</i>
</div>
<div id="footer2">
<i>test test test.</i>
</div>
</div>
</div>
</body>
</html>
有任何想法吗?