replaceWith Automatically Closes the Tag
Posted
by
Warrantica
on Stack Overflow
See other posts from Stack Overflow
or by Warrantica
Published on 2011-01-13T10:41:19Z
Indexed on
2011/01/13
10:53 UTC
Read the original article
Hit count: 106
jQuery
|replacewith
I have 3 divs and I want to replace the first div with an opening tag of another div and the third with the closing tag. This is what I meant:
<div>1</div>
<div>2</div>
<div>3</div>
When I tried to replace (using replaceWith()) the first div with <div class="foo">
and the third with </div>
, jQuery somewhat misinterpret it as:
<div class="foo"></div>
<div>2</div>
</div>
While what I actually want is:
<div class="foo">
<div>2</div>
</div>
Thank you in advance,
© Stack Overflow or respective owner