Take this HTML code:
<div id="mydiv">Hello World</div>
Doing:
$('#mydiv').html('Aloha World');
Will result in:
<div id="mydiv">Aloha World</div>
Doing:
$('#mydiv').replaceWith('Aloha World');
Will result in:
Aloha World
So html() replaces the contents of the element, while replaceWith() replaces the actual element.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…