Jason Foglia
Jason Foglia

Reputation: 2531

Is it possible to wrap a div with 2 additional divs in jQuery

<div id="childDivToWrapTwice">Content</div>

var parent = $("<div />");
var child = $("<div />");
child.wrap(parent);
$("#childDivToWrapTwice").wrap(child);

This doesn't seem to be working even though you would think it should.

Upvotes: 0

Views: 30

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388316

var parent = $("<div />");
var child = $("<div />");
$("#childDivToWrapTwice").wrap(parent).wrap(child);

Demo: Fiddle

Upvotes: 1

Related Questions