I have a table and this code to find the a href and make a whole row clickable:
$(document).ready( function() {
$('table tr').click(function() {
var href = $(this).find("a").attr("href");
if(href) {
window.location = href;
}
});
However, there is one problem and that's my right click do not offer me "Open link in new tab" option and window etc. stuff like on a normal a href link.
Using divs instead of table is not an option.
How to fix it?
Is there any jQuery plugin that ca nfix it for me?
My table looks like this (it's much bigger with more td's but just for illustration):
<table>
<tr>
<td>
<a href="http://example.com">Some link</a>
<span>Bla bla bla</span>
</td>
<td>
<span>Some text</span>
</td>
</tr>
<tr>
<td>
<a href="http://someotherlink.com">Some link</a>
<span>Other text</span>
</td>
<td>
<span>Something else</span>
</td>
</tr>
<tr>
...
</tr>
</table>
EDIT: I need to grab the a href value automatically like in my current code: $(this).find("a").attr("href");
EDIT 2: I need to be the whole tr clickable (as a block). which is possible using the method above. However, it is not possible to click on the row and select "Open link in a new tab". This option is available only when I hover over the a href. But I need it to be also on the whole row. So, if the user wants to open multiple new tabs using middle mouse button or right click and selecting "Open in a new tab" from the context menu, he can do it. Right now it is not possible.