Reputation: 11829
I want a clickable table. This code works in all browsers, except in IE8. I haven't tested in IE9, but it works in IE10. By not working I mean nothing happens when I click on the table. Why?
<a href="www.cnn.com" target="_blank" class="nonlink">
<table>
<tr>
<td>
<p>hello</p>
</td>
</tr>
</table>
</a>
This works of course:
<a href="www.cnn.com" target="_blank" class="nonlink">
hello
</a>
I tested the code in a clear webpage where no other code exists.
Upvotes: 0
Views: 1664
Reputation: 358
It'll obviously wont work since you using iligal way.
You cannot use <a>
tag outside table tag.
However you can allways use <a>
inside <p>
tag so the code will be vaild, like that:
<table>
<tr>
<td>
<p><a href="www.cnn.com" target="_blank" class="nonlink">hello</a></p>
</td>
</tr>
</table>
EDIT
Here is an alternative way for your code so the table empty space will be fixed.
$('td').on("click", function(){
window.location = ""; // Add whatever your window location (I.E. index.html)
});
Upvotes: 2
Reputation: 46047
It does work, but it's definitely not good practice. From your example you should be able to include the anchor in the cell.
<table>
<tr>
<td>
<p><a href="http://www.cnn.com" target="_blank" class="nonlink">hello</a></p>
</td>
</tr>
</table>
Click here for a demo.
Upvotes: 0