highlight table row after dynamically adding it

后端 未结 2 833
南旧
南旧 2021-01-21 12:58

looking at how i can highlight a table row after dynamically adding it with jquery my code seems to be adding the row with no problems, but its not highlighting the correct row<

2条回答
  •  野性不改
    2021-01-21 13:34

    I would assume that the effect would be applied to what ever tr:last was as that is the main selector.

    after() returns the jQuery object from the original selector $('#opponents tr:last') allowing you to continue chaining on to that main selector.


    DEMO - Using existing code, wrong row is highlighted


    Try separating the new row into it's own instead and applying the effect to it directly. Similar to this:

    var $newRow = $('datamore data');
    
    $('#opponents tr:last').after($newRow);
    $newRow.effect("highlight", {}, 3000);
    

    DEMO - Working DEMO of above code


提交回复
热议问题