hac*_*osh 13 html jquery html-table
将一行HTML表格作为链接的最佳方法是什么?我目前正在使用jquery对斑马条纹行进行突出显示onmouseover/off选定行,所以如果JavaScript是答案,请使用jquery.
Nic*_*unt 40
我只是用css:
<style>
table.collection {width:500px;border-collapse:collapse;}
table.collection tr {background-color:#fff; border-bottom: 1px #99b solid;}
table.collection tr:hover {background-color:#ffe;}
table.collection td {display:table-cell;border-bottom: 1px #99b solid; padding:0px;}
table.collection td a {text-decoration:none; display:block; padding:0px; height:100%;}
</style>
<table class="collection">
<tr>
<td><a href="#">Linky1</a></td>
<td><a href="#">Data1</a></td>
</tr>
<tr>
<td><a href="#">Linky2</a></td>
<td><a href="#">Data2</a></td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
hun*_*ter 18
$(document).ready(function(){
$("tr").click(function(){
/* personally I would throw a url attribute (<tr url="http://www.hunterconcepts.com">) on the tr and pull it off on click */
window.location = $(this).attr("url");
});
});
Run Code Online (Sandbox Code Playgroud)