jQuery Highlight Effect On Table Row Styled With Bootstrap
Asked Answered
M

2

8

Using Bootstrap 2.0 I've styled a table using .table-striped. I'm updating rows of data via ajax and when the update is complete, I want to highlight the row, which works on rows that don't have a background-color. So basically, the even rows highlight, the odd rows don't. I'm not sure why that is.

I might just be too tired right now but some advice would be appreciated.

I'm using the following code to trigger the highlight:

$("#row_" + id).effect("highlight", {}, 1500);
Mountbatten answered 25/2, 2012 at 2:59 Comment(0)
P
13

Run the effect not on the row, but on the cells within the row. All the rows are highlighting, both even and odd. The changing background colour of the odd rows just gets hidden because the table cells' colour is over top.

Pragmatic answered 28/2, 2012 at 22:30 Comment(2)
Thanks. Will try this tonight and report back.Mountbatten
It works like a charm. By the way, to my personal case (highlight last row after inserting it), my solution was: $('#table tr:last').find('td').effect('highlight', {color: '#4BADF5'}, 2000);Mackenie
N
2

Just to add to Pickle's answer that each cell within the row is above the row colour, see the code below for highlighting each cell instead:

$("#row_" + id +" td").effect("highlight", {}, 1500);

(this assumes that no cells are of type "th" on the row, but that can easily be added if required)

Notebook answered 24/10, 2012 at 10:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.