I have a table with 5 columns, with information, the last column is for actions (Edit, delete, etc). I'm trying to click on an edit icon to enable me to edit the text of all the TDs of the same row except for the last one, since it's a tools cell, but I can't do it. I have tried
!$(this).is('td:last');
$(this).not('td:last');
!$(this).is(':last');
$(this).not(':last');
I have not succeeded, what could be going wrong? This is the code.
$(document).on('click','.tool',function(){
var action = $(this).data('action'),
row = $(this).parents('tr'),
row_cloned = $(this).clone(),
id = parseInt(row.data('id'));
switch ( action ) {
case 'edit':
row.find('td').each(function(){
if( !$(this).is('td:last') ){
$(this).prop('contenteditable',true);
}
});
row.find('td:first').focus();
break;
});
You were very close to what you want. Just change your selector to like this
$(this).is(':last-child')
: