Multiple div wrap selector
I have two elements that I want to wrap with a new div.
<div class="bigfont-m capsletter"></div>
<div class="headfont6 text-overhide"></div>
Is it possible to immediately select both methods and use the .wrap()jQuery method ?
I know about multiple selector (,), but it doesn't work on my side.
I want the new div to be like this
<div>
<div class="bigfont-m capsletter"></div>
<div class="headfont6 text-overhide"></div>
</div>
+4
4 answers
You can use multiple selectors to select both elements, and then use .wrapAll () to wrap them in an element
$('.bigfont-m.capsletter, .headfont6.text-overhide').wrapAll('<div class="wrapper"/>')
Demo: Fiddle
+4
jQuery - select multiple classes
How to select an item with multiple classes?
$('bigfont-m.capsletter, headfont6.text-overhide') is your selector
0