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" />')
Comments
Post a Comment