Xeen
Xeen

Reputation: 7003

How can I wrap multiple elements in a wrapper with jQuery?

I have the following script that's wrapping one element just fine:

$('.brandModelWrapperGroup').each(function(){
   var divs = $(this).find(".brandModelWrapper")
   for(var i = 0; i < divs.length; i+=brandModelLineCount) {
     divs.slice(i, i+brandModelLineCount).wrapAll("<section class='brandModelLineWrapper'></section>")
   }
})

But I need it to wrap not just .brandModelWrapper, but also .brandModelView, how could I do that?

Upvotes: 0

Views: 42

Answers (1)

Milind Anantwar
Milind Anantwar

Reputation: 82241

Use comma separated multiple selector:

var divs = $(this).find(".brandModelWrapper").add($(this).find(".brandModelView"));

Upvotes: 2

Related Questions