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

Capture and play voice with Asterisk ARI -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -