alternative replaceWith() jquery without losing second element -



alternative replaceWith() jquery without losing second element -

example

<script type="text/javascript"> $(document).ready(function () { $("#exp1").replacewith($("#exp2")); }); </script> <div class="exp1">example 1</div> <div class="exp2">example 2</div>

when utilize code, lost exp2 ( mean illustration 2 not showing ), display illustration 1 has been replace illustration 2.. how not lose , replace exp1 exp2, , displays result below

<div class="exp2">example 2</div> <div class="exp2">example 2</div>

please help me .. thanks

you should clone() element utilize replacewith method. need utilize class selector

use

$(document).ready(function () { $(".exp1").replacewith($(".exp2").clone()); });

demo

jquery replacewith

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -