<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.