Jquery 表行用作链接,但最后一行为TD';的内容必须被跳过

Jquery 表行用作链接,但最后一行为TD';的内容必须被跳过,jquery,html,Jquery,Html,以下是单个表行的示例: <tr class="altrow"> <td><a href="/companies/view/59">Delta company</a></td> <td></td> <td>John</td> <td>Doe</td> <td>Green streer</td> <td><a href="/co

以下是单个表行的示例:

<tr class="altrow">
<td><a href="/companies/view/59">Delta company</a></td>
<td></td>
<td>John</td>
<td>Doe</td>
<td>Green streer</td>
<td><a href="/companies/edit/59" target="_blank"><img src="/img/edit.png" alt="edit" width="18px" height="18px" title="edit" /></a></td>
    </tr>
因此,它基本上找到了第一个链接,即。然后,如果用户单击表行上的任意位置,他将被重定向到该链接。问题是,我在上一个TD中包含了另一个链接的图像。单击图标时,图标的链接会在另一个选项卡中打开,但整个TR的链接也会打开

我想做的是:如果单击图标,则只打开第二个链接

非常感谢您的帮助

window.location = $(this).find('a').eq(1).attr('href');

eq(1)
将所有标记的查找重复到第二个。

您可以尝试的是

$('tr.altrow').click( function() {
    window.location = $(this).find('a:last-child').click();
}).hover( function() {
    $(this).toggleClass('hover'); 
});

这应该具有相同的效果

只需检查您正在单击的内容:

$('tr.altrow').click( function(e) {
    if(!$(e.target).closest('[target="_blank"]').length) window.location = $(this).find('a').attr('href');
})

如果停止所有

$('tr.altrow').click( function(e) {
    if(!$(e.target).closest('[target="_blank"]').length) window.location = $(this).find('a').attr('href');
})
$("tr.altrow a").click(function(e){
    e.stopPropagation();
});