How to select individual cell instead of the whole role?
How to select individual cell instead of the whole role?
Hi, I am wondering if there is a way to select individual cells in a role instead of the whole role.
Here is the code I used to select a row:
[code]
$('#example tr').live('click', function() {
if ( $(this).hasClass('row_selected') )
$(this).removeClass('row_selected');
else
$(this).addClass('row_selected');
} );
[/code]
I tried to change 'tr' to 'td' or change from 'row_selected' to 'select'.
It doesn't seem to work.
Cheers.
Here is the code I used to select a row:
[code]
$('#example tr').live('click', function() {
if ( $(this).hasClass('row_selected') )
$(this).removeClass('row_selected');
else
$(this).addClass('row_selected');
} );
[/code]
I tried to change 'tr' to 'td' or change from 'row_selected' to 'select'.
It doesn't seem to work.
Cheers.
This discussion has been closed.
Replies
$('#example tbody td').live('click', function() {
if ( $(this).hasClass('cell_selected') )
$(this).removeClass('cell_selected');
else
$(this).addClass('cell_selected');
} );
[/code]
should work. You'd need a "cell_selected" class of course to highlight the cell...
Allan
I tried your code but doesn't seem to be working. I have added the following codes into the CSS, but the table doesn't seem to be selectable.
[code]
table.display td.even.cell_selected td {
background-color: #B0BED9;
}
table.display td.odd.cell_selected td {
background-color: #9FAFD1;
}
[/code]
Is this right?
[code]
table.display tr.even td.cell_selected {
background-color: #B0BED9;
}
table.display tr.odd td.cell_selected {
background-color: #9FAFD1;
}
[/code]