Alex Rivera | Logout

Jquery Datatables - Make whole row a link

Asked 2011-09-22T23:14:27.203
24

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.

Edit
Report

1 Answer

11

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');
});

You'll probably want some hover event handling there as well, to give users visual feedback before they click a row.

answered 2011-09-22T23:22:26.357

Your Answer