jQuery数据表-使整行成为链接 [英] Jquery Datatables - Make whole row a link
问题描述
这也许很简单,但似乎无法弄清楚.使用jquery数据表,如何使每一行都可单击以仅链接到正常页面?因此,如果有人将鼠标悬停在任何行上,则整行将突出显示并可以单击,并链接到我希望在单击时链接到的任何URL.
This maybe simple, but cant seem to figure it out. Using jquery datatables how can I make each row clickable to just link to a normal page? So if someone moused over any of the row the whole row will hightlight and be clickable and link to whatever url I would want it to link to when clicked.
推荐答案
使用香草< table>
做到这一点很简单,但是我不明白为什么这不起作用使用jQuery DataTables之一.
It's simple enough to do this with a vanilla <table>
, but I don't see why this wouldn't work with a jQuery DataTables one either.
$('#myTableId').on('click', 'tbody > tr > td', function ()
{
// 'this' refers to the current <td>, if you need information out of it
window.open('http://example.com');
});
您可能还希望在其中进行一些 hover
事件处理,以便在用户单击行之前为其提供视觉反馈.
You'll probably want some hover
event handling there as well, to give users visual feedback before they click a row.
这篇关于jQuery数据表-使整行成为链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!