jquery - open div tag and close it in another place by javascript -
is possible using javascript open tag, example div#js , insert closing tag in place want, on example below?
<div id="first"></div> <div id="js"> <div id="second"></div> <div id="third"></div> </div> <div id="fourth"></div>
if start with:
<div id="first">1</div> <div id="second">2</div> <div id="third">3</div> <div id="fourth">4</div>
and need structure:
<div id="first">1</div> <div id="js"> <div id="second">2</div> <div id="third">3</div> </div> <div id="fourth">4</div>
the can use $('#second').wrap('<div id="js"></div>').after($('#third'))
.
see demo below:
$('#second').wrap('<div id="js"></div>').after($('#third'));
#js { color: blue; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="first">1</div> <div id="second">2</div> <div id="third">3</div> <div id="fourth">4</div>
wiki
Comments
Post a Comment