I\'m wondering if it\'s posible to switch positions of two divs with jQuery.
I have two div like this
STUFF ONE
Here's an example:
http://jsfiddle.net/52xQP/1/
First you want to clone the elements. Then, check a condition if div2 is empty. Then, do the swap:
div1 = $('#div1');
div2 = $('#div2');
tdiv1 = div1.clone();
tdiv2 = div2.clone();
if(!div2.is(':empty')){
div1.replaceWith(tdiv2);
div2.replaceWith(tdiv1);
tdiv1.addClass("replaced");
}