CODE CODIFY.CLUB

jQuery detach and insertAfter

HTML


<div id="container">
 <div id="one">one</div>
 <div id="two">two</div>
 <div id="three">three</div>
</div>

CSS


#container {width: 500px; height: 500px; background: gray;}
#one {width: 100%; height: 33%; background: yellow;}
#two {width: 100%; height: 33%; background: red;}
#three {width: 100%; height: 33%; background: green;}

JS


$("#three").each(function(){
 $(this).detach().insertAfter("#one");
});

V!ral

Developer, Technology aficionado, Beer Lover and founder of codify.club Network. Who shares a keen interest about website development, health issues, cancer awareness and other fun stuff.

Add comment

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Most popular

Most discussed