<div id='one' class='foo'>Hello</div>
$('#one').replaceWith("<div id='one'>World</div>")
Above code is producing
<div id='one' class='foo'>World</div>
However the desired output is
<div id='one'>World</div>
Notice that replaceWith is changing the content inside the div but not the attributes of the div itself.
As with the others that have commented on this, I can not reproduce the problem.
That causes
this to change to:
However, alternatively you could use this:
Mind you those are on click, you could remove the click and do it however you like.
See here:
http://jsbin.com/adesi3/edit