You need to change the class as well
function update_rows() {
$("tr:even").css("background-color", "#aaa").find('a').removeClass('sam').addClass('sams');
$("tr:odd").css("background-color", "#eee").find('a').removeClass('sams').addClass('sam');
}
Demo: Fiddle
Use :nth-child if want to support only modern browsers - Demo: Fiddle
tr:nth-child(odd) a {
background-color:#FF00FF;
}
tr:nth-child(even) a {
background-color:#0000FF;
}
tr:nth-child(odd) {
background-color:#aaa;
}
tr:nth-child(even) {
background-color:#eee;
}
then
$(function () {
$("a").click(function () {
$(this).closest('tr').remove();
});
});
Also note: use $(this).closest('tr').remove()
instead of $(this).parent().parent().remove()