开发者

removing tr from table

I am drawing a grid using HTML and each tr element has it's own id. I want to be able to remove a tr on a button click, but not have to redraw the whole grid to show that the row has been deleted. I can do this 开发者_Python百科using .hide(), but the problem is that I need to call a function to stripe my rows after, and since the row is still considered there, the striping doesn't work properly. Can anybody suggest a solution?


If you need a call back then write a function that does the remove and then provides a callback function.

function remove(element, callback)
{
    $(element).remove();

    if ( typeof callback !== 'undefined' ) callback();
}

Then you could use it like this:

remove('#myId', function() {

    // Do stuff.

});


Couldn't you just:

$('tr_selector').remove();
if (!$('tr_selector')) {
   //doesn't exist - do stuff
}

Ignore my answer - Seth's is better...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜