Clicking a row except for the first td
datatables, jquery
Solution
Use target of click within row, and check the index of TD
Simplified DEMO: http://jsfiddle.net/WLR9E/
jQuery('#dyntable tbody tr').live('click', function (evt) {
var $cell=$(evt.target).closest('td');
if( $cell.index()>0){
openMessage(oTable, this);
}
});
live() is deprecated , if using jQuery >= 1.7 convert to on(). Following assumes main table is a permanent asset in page.
jQuery('#dyntable').on('click','tbody tr', function (evt) {
var $cell=$(evt.target).closest('td');
if( $cell.index()>0){
openMessage(oTable, this);
}
});
This line in your code is redindant, it simply returns the same as `this`
nTr = jQuery(this)[0];
Problem
I am trying to click a table row and perform an action. However if they click the first `<td>` cell I do not want that to perform the action. Here is the code I have so far: ``` jQuery('#dyntable tbody tr').live('click', function () { nTr = jQuery(this)[0]; openMessage(oTable, nTr); }); ``` This works as intended, except the first `<td>` has a check box, so if they click in that cell I do not want to call the o`penMessage(oTable, nTr);` function. I also still need `nTr` to = the contents of the row.