jQuery: What to do when replaceWith() doesn’t work
Posted: October 20th, 2008 | Author: Panos Karageorgakis | Filed under: Development, Web, jQuery | Tags: jQuery, replace, trick | No Comments »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');
