I have a <table> where each <td> holds only an anchor. I’d like users to be able to click anywhere in the cell to visit that reference rather than only on the anchor text itself. I imagine there must be a bit of jQuery to do this easily. Can anyone help?
Edit: To complicate things, my td‘s have some top and bottom padding. A display: block; rule doesn’t seem to work in this case. I’ve edited the example:
CSS:
table#mainmenu td {
padding: 9px 8px 5px;
border: none;
border-bottom: 1px solid #ccc;
border-left: 1px dotted;
text-align: left;
}
Example:
<table>
<tr>
<td><a href="foo.html">Foo</a></td>
<td><a href="bar.html">Bar</a></td>
</tr>
<tr>
<td><a href="foobar.html">FooBar</a></td>
<td><a href="barfoo.html">BarFoo</a></td>
</tr>
</table>
Just make the A tag
display: block.http://jsfiddle.net/userdude/6VZ8t/
Or, if you insist on jQuery:
http://jsfiddle.net/userdude/a2EAz/
EDIT
Since I wasn’t able to find a CSS-only way to select a parent TD of a child A, this solution does use jQuery:
http://jsfiddle.net/userdude/Mekjg/1
Note that this is running from
$(document).ready();.EDIT 2
As mu is too short notes, negative margins should work (and no jQuery):
http://jsfiddle.net/ambiguous/seqpp/