Reputation: 3541
I have the following code:
var parentQuestionDiv = $('.ui-droppable').find("[Question='" + parentQuestionId + "']");
var nestedQuestionDiv = $(this).parent();
$(parentQuestionDiv, nestedQuestionDiv).wrapAll("<div id='nestedQuestionGroup' style='border: 1px solid #000'></div>");
I want to take the two divs, and place the inside a new parent div. The problem I have is that parentQuestionDiv
is only wrapped. Not the nestedQuestionDiv
.
If I change $(parentQuestionDiv, nestedQuestionDiv
) to $(nestedQuestionDiv, parentQuestionDiv)
, the nestedQuestionDiv
is only wrapped.
So why does it not work with both divs? How can I wrap both the divs?
Upvotes: 1
Views: 66
Reputation: 115212
The second argument in jQuery is for defining the context for searching the element so nothing would happen. To get it work you need to combine them using add()
method and then use the wrapAll()
method.
parentQuestionDiv.add(nestedQuestionDiv).wrapAll("<div id='nestedQuestionGroup' style='border: 1px solid #000'></div>");
Upvotes: 1
Reputation: 74420
You need to add it in current set:
parentQuestionDiv.add(nestedQuestionDiv).wrapAll("<div id='nestedQuestionGroup' style='border: 1px solid #000'></div>");
Upvotes: 0