tags:

views:

904

answers:

3

On most of tables, or anything that has lot of data rows, I have seen that when something is edited that row becomes yellow for a while and then after a while goes back to its normal state.

I have a data table with about 500 rows. User can click edit on anything, edit that row on a new page, and come back to page with all 500 rows. When user comes back to page with 500 rows I want to make the last edited row highlight for a while.

I know we can use addCss but how will I remove the css after a while?

can someone who has done this please suggest a way or show an example?

I am doing this but getting a JS error:

$('#'+test).effect("highlight", {}, 3000);

where '#'+test is a id of a tr

+2  A: 

Give Highlight a try. This is the same thing that happens to your answer on SO when you hit "Post Your Answer".

Suppose you have this HTML:

    <table id="myTbl">
        <tr>
            <td>Frist</td>
            <td>Row</td>
        </tr>
        <tr>
            <td>Second</td>
            <td>Row</td>
        </tr>
    </table>

CODE:

$(document).ready(function(){
    $("#myTbl tr:first-child").effect("highlight", {}, 3000);
}); //this is from jquery.com page.
TheVillageIdiot
highlight seems to only work on 'div'. I am trying to make it work on 'tr' so that I can make the whole row highlight
Omnipresent
I've modified answer. It does work for tr, td, li etc.
TheVillageIdiot
+1  A: 

What about something like this

$(window).load(function() { // that way, the transition won't start until the whole page has loaded. note I think you may only have one of these events.

    $('#my-table tr:last td').addClass('highlight');

    setTimeout(function() {
        $('#my-table tr:last td').animate( { backgroundColor: 'transparent' }, 1000);

    }, 3000);



});

Now if you set up a class highlight in your CSS, the page should should show your last table row highlighted, and it should begin to fade to normal in roughly 3 seconds.

alex
A: 

Try this. You need jQuery UI in order to use the highlight effect.

$('a').click(function(){
    $('tr').effect('highlight', 3000);
});
Andrew