我的 HTML:
<div class="mainDiv">
<p>This is a paragraph</p>
<div class="innerDiv">This is a div</div>
This is what I want to wrap
</div>
我想要的是:
<div class="mainDiv">
<p>This is a paragraph</p>
<div class="innerDiv">This is a div</div>
<div class="wrapper">
This is what I want to wrap
</div>
</div>
我试过了:
$('.mainDiv').find(".innerDiv").next().wrap('<div class="wrapper" />')
但它不起作用。我怎样才能达到上述结果?