将表放在超链接中 - 不在IE中工作

Jam*_*mes 3 html internet-explorer html-table hyperlink

我在超链接中有一个表:

<a href="/"><table><tr><td>...</td></tr></table></a>
Run Code Online (Sandbox Code Playgroud)

在所有浏览器中,将鼠标悬停在表格上会将指针更改为一只手,而通过某些CSS,表格背景会改变颜色(因此它看起来"突出显示").

但是,在Internet Explorer中,单击该表无效.在Firefox和Chrome中,它遵循预期的超链接.

点击后如何让IE跟随链接?

Ble*_*der 8

您不能在内联元素中嵌套块级元素,并期望获得正确的结果(在此处插入引文).

您可以向表中添加一些CSS样式并应用onclick处理程序,使其像超链接一样:

<table style="fakeLink" onclick="window.location = '/';">...
Run Code Online (Sandbox Code Playgroud)

fakeLink班级:

.fakeLink
{
  color: blue;
  border-color: blue;
  cursor: pointer;
  text-decoration: underline; /* Not sure if this is possible. */
}
Run Code Online (Sandbox Code Playgroud)

以及演示两种技术的演示:http://jsfiddle.net/qNGrp/4/.我没有IE,但我认为只有一个能正常工作.