[英]How to add a hyperlink to a Table Row <tr>
I created a table, but i can't get the HTML link working, which I want to include in the tablerow. 我创建了一个表,但是我无法使HTML链接正常工作,我想将其包括在表行中。
<table class="list" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<th width="10%"></th>
<th width="30%">Titel</th>
<th width="20%">Typ</th>
<th width="10%">Jahr</th>
<th width="14%">Anzahl</th>
<th width="8%"><img title="Dub" src="IMG" alt="Dub" /></th>
<th width="8%"><img title="Sub" src="IMG" alt="Sub" /></th>
</tr>
<td><img src="IMG" alt="" /></td>
<td style="padding-top: 15px;">XYXYXYXYXY</td>
<td style="padding-top: 15px;">XCXYX</td>
<td style="padding-top: 15px;">XYXYX</td>
<td style="padding-top: 15px;">XXXXX</td>
<td style="padding-top: 15px;"><img src="XYXYXYXYXY" alt="" /></td>
<td style="padding-top: 15px;"><img src="XYXYXYXYXY" alt="" /></td>
</tr>
<td><img src="XYXYXYXYXY" alt="" /></td>
<td style="padding-top: 15px;">XYXYXYXYXY</td>
<td style="padding-top: 15px;">XYXYXYXYXY</td>
<td style="padding-top: 15px;">XXXXX</td>
<td style="padding-top: 15px;">XYXYX</td>
<td style="padding-top: 15px;"><img src="XYXYXYXYXY" alt="" /></td>
<td style="padding-top: 15px;"><img src="XYXYXYXYXY" alt="" /></td>
</tr>
</tbody>
</table>
A fiddle: http://jsfiddle.net/pjPTd/ 小提琴: http : //jsfiddle.net/pjPTd/
I tried it with using jquery, but i couldnt get it work. 我尝试使用jquery,但无法正常工作。
your question is not clear at all, if you want to add a link to a table cell you can simply use the <a>
tag, see bellow: 您的问题根本不清楚,如果您想向表单元格添加链接,则可以简单地使用
<a>
标记,请参见以下信息:
<a href="http://google.com"> click to visit google </a>
add this inside a <td>
and you will get a link that takes you to google. 将其添加到
<td>
,您将获得一个链接,该链接将您带到Google。
next time make your question clear and general so that others can use it as well. 下次让您的问题清楚而笼统,以便其他人也可以使用。
update: 更新:
if you mean by clickable a button then you should probably visit button tag w3schools 如果您是指点击按钮,那么您应该访问按钮标签w3schools
Add a class and then an href to each row. 向每行添加一个类,然后添加一个href。
<tr class='js-clickable' href='http://www.ebay.com'>
Then create a click event, grab the URL, and finally redirect the user to that link. 然后创建一个click事件,获取URL,最后将用户重定向到该链接。
$('.js-clickable').on('click', function() {
var URL = $(this).attr("href");
alert('you will be redirected to' + ' ' + redirectURL);
window.document.location = URL;
});
通过使用以下代码,超链接会将<tr> <td><a href="http://google.com">click to visit google</a></td> </tr>
到表格行中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.