Friday, 17 June 2016

Wrap all into one div

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>
banner
Previous Post
Next Post

0 comments: