JQuery: delete really delete?

I am trying to delete a table row using jQuery and while it disappears from the screen and therefore seems to work, in Firebug I still see the code for it. There are form elements in this line, and so I want to understand if the line is really deleted or not, because I would not want these values ​​to be sent. So, is it really remove the delete? Below is the code I'm using ... Maybe I'm doing it wrong?

if($('.delete')) { $(".delete").live('click', function(event) { $(this).closest('tr').remove(); }); } 
+7
jquery
source share
5 answers

The source of the page is not updated using Javascript functions. If you check the DOM in Firebug, you can see the reflected changes.

+9
source share

It completely removes the item from your DOM. I think you can look at the wrong element, because if it is actually deleted on your screen, firebug should reflect this change.

Your code looks good.

. Delete () Link

+1
source share

It is right. The remove () method does not remove items. In jQuery in Action, it says, β€œNote that, like many other jQuery commands, the completed set is returned as a result of this command. Elements removed from the DOM still reference this set (and therefore not yet for garbage collection) and can be additionally used when using other jQuery commands ... "I searched, and this does not look like jQuery, which actually removes elements. Therefore, I think you should do this using the old JavaScript DOM functions.

+1
source share

Yes, jQuery remove() really removes elements from the DOM.

There is probably something wrong with your code.

0
source share

Yes Yes.

I played with him the other day. You can see in firebug (and other browser debuggers) that the element disappears.

0
source share

All Articles