If both nodes are the only children of the same parent, just do this:
$('#parent').prepend($('#parent').children().last());
This should take whichever element is currently last, and make it first.
See http://jsfiddle.net/alnitak/wt4VZ/ for demo.
If that doesn't apply, try:
var el1 = $('#element1');
var el2 = $('#element2');
var tag1 = $('<span/>').insertBefore(el1); // drop a marker in place
var tag2 = $('<span/>').insertBefore(el2); // drop a marker in place
tag1.replaceWith(el2);
tag2.replaceWith(el1);
The idea here is that the two temporary spans just act as place holders into which the original elements will be dropped, without serialising or otherwise messing with those elements.
See http://jsfiddle.net/alnitak/bzKXn/ for a demo of that.