开发者

jQuery ::: Does remove really remove?

I'm trying to remove a table row usin开发者_JAVA技巧g jQuery, and while it disappears from the screen, and therefore, appears to work, in Firebug, I can still see the code for it. There are form elements in this row, and so, I want to understand whether the row is truly being deleted or not, because I wouldn't want those values submitted. So, does remove really remove? Below is the code I'm using... Maybe I'm doing it wrong?

if($('.delete')) {
            $(".delete").live('click', function(event) {
                $(this).closest('tr').remove();
            });
        }


The source of a page doesn't update with Javascript functions. If you inspect the DOM in Firebug you should be able to see the changes reflected.


It removes the element completely from your DOM. I think you may be looking at the wrong element, because if it is in fact being removed on your screen, firebug should reflect the change.

Your code looks fine.

.Remove() Reference


That's right. The remove() method doesn't remove the elements. In "jQuery in Action" is written that "Note that, as many other jQuery commands, the wrapped set is returned as the result of this command. The elements that were removed from the DOM are still referenced by this set (and hence not yet eligble for garbage collection) and can be further operated upon using other jQuery commands... " I've been searching and it doesn't seem to be a jQuery that actually removes the elements. So I think you should do it using the old DOM JavaScript functions.


Yes, jQuery's remove() does really remove the elements from the DOM.

There probably is something wrong in your code.


Yes it does.

I was playing with it the other day. You can see in firebug (and other browser debuggers) that the element disappears.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜