html - Wrap two specific elements with jquery -


i have elements like

<div id="one">one</div> <div id="two">two</div> <div id="three">three</div> <div id="four">four</div> <div id="five">five</div> 

now want wrap div tag around 2 elements id "two" , "three" this:

<div id="one">one</div> <div class="wrapped">     <div id="two">two</div>     <div id="three">three</div> </div> <div id="four">four</div> <div id="five">five</div> 

with "wrapall" function can target elements same class think like:

$(document).ready(function(){     $( "div" ).wrapall( "<div class='wrapped' />"); }); 

i know give 2 divs same class jquery first , wrap them i hope there more elegant way.

you can $('#two, #three').wrapall('<div class="wrapped" />')

jsfiddle example


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -