Jquery 数据表 - 使整行成为链接 [英] Jquery Datatables - Make whole row a link

查看:29
本文介绍了Jquery 数据表 - 使整行成为链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能很简单,但似乎无法弄清楚.使用 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.

推荐答案

使用普通的

很简单,但我不明白为什么这不起作用使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆