array(5) {
[0]=>
array(4) {
["type"]=>
string(4) "link"
["shares"]=>
array(1) {
["count"]=>
int(1)
}
["id"]=>
string(30) "252XXXXX_101XXX7"
["reactions"]=> <---- Empty
array(0) {
}
}
[1]=>
array(4) {
["type"]=>
string(5) "photo"
["shares"]=>
array(1) {
["count"]=>
int(916)
}
["id"]=>
string(30) "252X_101543XXX7"
["reactions"]=> <---- Empty
array(0) {
}
}
[2]=>
array(4) {
["type"]=>
string(4) "link"
["shares"]=>
array(1) {
["count"]=>
int(405)
}
["id"]=>
string(30) "2526XXX_101XXXX7"
["reactions"]=> <---- Empty
array(0) {
}
}
我有这个html页面,我需要将整行作为锚标记,所以当我将鼠标悬停在行上并单击它时,我可以转到另一页。但是当我尝试执行它时,DOM会将锚标记抛出表标记之外,但它不起作用。我该如何实现呢?
答案 0 :(得分:3)
您无法在<a>
中添加<table>
代码。
您只能在<td>
代码中添加内容。
尝试使用onclick
document.location.href+='#anchor'; return false;
属性
示例强>
table {
height:200px;
}
#test{
height:400px;
background-color:grey;
}
<table>
<tr onclick="document.location+='#test';return false;">
<td>
click
</td>
<td>
click
</td>
</tr>
</table>
<div class="test" id="test"></div>
<强>更新强>
要转到其他页面,请使用
window.location.href="url";
而不是
document.location
答案 1 :(得分:1)
你不能。
表格单元格中可以存在链接,也可以完全包含表格。中间没有选择。
您可以在第一个单元格中添加一个链接,然后应用一些JavaScript:
jQuery("tr").on("click", function (e) {
location = jQuery(this).find("a").attr("href");
});
答案 2 :(得分:1)
这不是有效的标准。您可以使用JS作为acnchor。例如:
$('.table-bordered tr td').on("click", function(){
window.location.href= $(this).parent().attr('href');
});
TR定义可以是:
<tr href="http:/www.yahoo.com">.....</tr>