$('#first').insertAfter('#second');
// или аналогично
// $('#second').insertBefore('#first');
cloneNode
replaceChild
<div id="inp1"></div>
<div id="inp2"></div>
inp1.parentNode.insertBefore(inp1, inp2);
function replaceElements(elemOne, elemTwo){
var next = elemOne.nextElementSiblings,
parentOne = elemOne.parentNode,
parentTwo = elemTwo.parentNode
;
parentTwo.insertBefore(elemOne, elemTwo);
if(next){
parentOne.insertBefore(elemTwo, next);
}else{
parentOne.appendChild(elemTwo);
}
}
replaceElements(inp1, inp2);