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

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -