How to wrap all into one div
Html
<div class='main'>
<div class="a">a<div>
<div class="b">b<div>
<div class="c">c<div>
<div id="d">d<div>
<div class="e">e<div>
<div id="f">f<div>
</div>
JQuery:
jQuery('.a, #d, .b, .c').wrapAll(jQuery('<div>').addClass('wrapbharat') );
Output after running jQuery will
<div class="main">
<div class="wrapbharat"><div class="a">a<div>
</div></div><div class="b">b<div>
</div></div><div class="c">c<div>
</div></div><div id="d">d<div>
<div class="e">e<div>
<div id="f">f<div>
</div>
Html
<div class='main'>
<div class="a">a<div>
<div class="b">b<div>
<div class="c">c<div>
<div id="d">d<div>
<div class="e">e<div>
<div id="f">f<div>
</div>
JQuery:
jQuery('.a, #d, .b, .c').wrapAll(jQuery('<div>').addClass('wrapbharat') );
Output after running jQuery will
<div class="main">
<div class="wrapbharat"><div class="a">a<div>
</div></div><div class="b">b<div>
</div></div><div class="c">c<div>
</div></div><div id="d">d<div>
<div class="e">e<div>
<div id="f">f<div>
</div>
0 comments: