This blog is far from finished, but feel free to enjoy the content.

jQuery: What to do when replaceWith() doesn’t work

Posted: October 20th, 2008 | Author: Panos Karageorgakis | Filed under: Development, Web, jQuery | Tags: , , |

Nothing’s perfect in this world and jQuery is not the exception to prove the rule. Sometimes the replaceWith() function doesn’t seem to work, no matter what you do. It looks like the function does nothing, and that’s a problem. But don’t bother; this will do the trick:

instead of

$('#someElement').replaceWith('something');

use this:

$('#someElement').empty().append('something');


Leave a Reply