views:

34

answers:

2

Hi Im trying to replace some html with Jquery, this is what I got so far.

 $(".old").html($(".new").html());

This almost work. Only that the .new is being copied, instead of replacing. I wan't to Cut/Paste instead of Copy/Paste

+2  A: 

This could work: $('.old').empty().append($('.new'));. It would move the element instead of duplicating.

Reinis I.
Thx, this worked :-)
gulbaek
I changed `.html('')` to `.empty()` since that looks better.
Reinis I.
+1  A: 

This should explain how to move DOM elements with jQuery.

Jakob