1

I have a function that deletes row like this:

function DeletePublisher(element, publisherid) {


jConfirm('Are you sure you want to delete this publisher?', 'Delete publisher', function (r) {
    if (r) $.post('includes/publishers/delete-publisher.php?publisherid=' + publisherid, 
    function(data) {
            if ($.trim(data) == 'error') {
            $.jGrowl('This publisher was already deleted', { header: '<strong style="text-align:center;">ERROR</strong>' });    
            $(element).parents('tr').remove();
            } else {
            $(element).parents('tr').remove();
            $.jGrowl('Publisher deleted');       
            }
        });
});

Now this works perfectly, but after row is deleted other rows are not updated classes (odd and even classes). So after I delete a row (in this example second TR is deleted:

<tr class="odd">
<tr class="even">
<tr class="odd">
<tr class="even">

I am getting it like this:

<tr class="odd">
<tr class="odd">
<tr class="even">

Now I am not sure if this is my error or I am missing something ?

4

1 回答 1

4

您需要再次根据奇偶数删除所有类并添加类

$('tr').removeClass();

// Now add class names again

$('tr:odd').addClass('odd');
$('tr:even').addClass('even');
于 2012-09-24T09:23:40.070 回答