problemas para quitar el elemento usando remove ()

Im having some trouble removing part of a cloned element:

console.log($(this).closest('tr').clone().find('td:last')); //this is the td that i want to remove
            $(this).closest('tr').clone().remove('td:last').append('<td><input type="button" value="Del" class="removesystem"/></td>').appendTo('.targetbox table'); //doesnt get removed here. i tried with .end() after remove() as well, without any success.

Have i missed something? Thanks

preguntado el 08 de noviembre de 11 a las 10:11

Share some markup or a jsFiddle. -

3 Respuestas

Remove only works on selected elements see the documentation:

Select the correct element and remove it:

$(this).closest('tr').clone().find('td:last').remove().end().append( yadda yadda yadda )

respondido 08 nov., 11:14

Creo que el .remove(/*filters*/) accespts only filters, of the selected elements,

so you should do this.


$(this).closest('tr').clone().find('td').remove(':last').append('<td><input type="button" value="Del" class="removesystem"/></td>').appendTo('.targetbox table');

también quitar console.log(); as it may not work, if console is not open

respondido 08 nov., 11:14

Remove returns the removed element - Kristoffer Sall-Storgaard

I didn't say anything about the return, I said it accepts as an attr the selectors filtered to be removed. $('td').remove(':last'); it will remove the last td as oppose to every td - ola

Delete a clone? Append to a deleted object?


Respondido 30 Jul 12, 11:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.