ajax jquery - track changes to table
Im updating a particular table with ajax usi开发者_如何学编程ng jquery every 5 seconds. I wish to highlight in yellow, any row that has been freshly inserted or changed. How do I keep track of what has changed ? Can this be done in jquery ? (My backend is django/python)
Some early morning coding:
$(document).ready(function(){
var myInsert = function(row){
var $test = $('#mytest'),
$row = $(row),
$tr = $row.slice(0),
col = 0;
var fade = setInterval(function(){
$tr.css('background-color', 'rgb(255,255,'+col+')');
if(col < 255)
col+=5;
else clearInterval(fade);
}, 33);
$test.append($row);
};
var newrow = '<tr><td>new1</td><td>new2</td><td>new3</td></tr>';
$(document.body).bind('click', function(){
myInsert(newrow);
});
});
I guess you need to adapt some parts (I don't know how your dynamic HTML looks like). But I hope you get the general idea.
working example: http://www.jsfiddle.net/LrCs2/1/
精彩评论