jquery - wrapInner() of body until a specified element -


using below html:

<body>    <h1>foo</h1>    <div>a</div>    <div>b</div>    <h4>bar</h4>    <div>c</div>    <div id="wrap-until"></div> </body> 

i can wrap whole of body section using $('body').wrapinner('<div class="content"></div>'); but how can wrap body content until wrap-until div element, looks like:

<body>    <div class="content">       <h1>foo</h1>       <div>a</div>       <div>b</div>       <h4>bar</h4>       <div>c</div>    </div>    <div id="wrap-until"></div> </body> 

note: content inside body different #wrap-until element available.

you can grab required elements , use not() exclude wrap-until element wrapall(), this:

$('body > *').not('#wrap-until').wrapall('<div class="content"></div>'); 

working example


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -