HTML表格行链接在新标签页中打开 [英] HTML table row link open in new tab
本文介绍了HTML表格行链接在新标签页中打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试向表行添加链接,并在单击时打开新标签.
I'm trying to add link to table row and open new tab when clicked.
以下解决方案可行,但我需要在新标签页中打开页面.
Solution below works, but i need to open page in new tab.
JavaScript:
Javascript:
$(document).ready(function () {
$('#orders-table tr').click(function () {
var href = $(this).find("a").attr("href");
if (href) { window.location = href; }
});
});
HTML:
<tr href="/order?id=[ORDER_ID_LOCAL]" target="_blank">
推荐答案
使用 const
或 let
而不是var
和适当的缩进.还要从tr
HTML标记中删除href
和target
属性.
Use window.open
, const
or let
instead of var
and proper indentation. Also remove the href
and target
attributes from the tr
HTML tag.
这篇关于HTML表格行链接在新标签页中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文