MartinZPetrov
MartinZPetrov

Reputation: 316

Wrap a set of divs with the same style

I have a set of divs containing different styles within a div. I want all those which match a certain class to be wrapped in a parent div programmatically. How can we implement this? Any ideas?

Upvotes: 1

Views: 63

Answers (2)

plushyObject
plushyObject

Reputation: 1131

Good ol' jQuery (haters gonna hate):

$("<p>").wrap("<div></div>");

Upvotes: 1

empiric
empiric

Reputation: 7878

There is a function .wrap() or .wrapAll() for that in jQuery:

$( ".class" ).wrap( "<div class='parent'></div>" );

If you could post some code, at least you html, I would be easier to find an answer wich fits your needs.

Upvotes: 1

Related Questions