javascript - How to mutually replace (change) 2 div nodes in DOM with jQuery? -


say have 2 node references in variables nodea , nodeb. mutually replace them each other in dom, keeping attributes , attached event handlers etc.

how can accomplish jquery? tried .replacewith(...) see works html text, , keep dom object itself.

there 2 .replacewith(...) call. , second 1 on node, not in dom... seems not working...

thanks in advance

it simmilar switch variables, need think in terms of dom.

var temp = $('<div>');  temp.insertafter(first); first.insertafter(second); second.insertafter(temp); temp.remove(); 

js fiddle: http://jsfiddle.net/qsutq/


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -