There appears to be a bug in the jQuery 1.4 implementation of
replaceWith.  If you try to replace an element with just plain text,
jQuery removes the element altogether and does not swap in the text.
It works fine if the text is surrounded by tags.  For example:

<div id="foo">this is some text</div>

Doing: $("#foo").replaceWith("hello world") will remove the div and
anything inside it
Doing: $("#foo").replaceWith("<b>hello world</b>") works fine!

As a workaround for the meantime, I am doing this:
x = $("#foo").parent();
$("#foo").replaceWith("<hack>hello world</hack>");
x.html(x.html().replace(/<[\/]*hack>/g,''));

Any ideas?  Is this a known bug already?

Thanks!

J

Reply via email to