wrap
The wrap method is used to wrap a layer of elements around the target element. Before performing the wrap operation, the initialization of the $ method is automatically executed, so you can directly fill in the specific element string or object.
I am 1
I am 2
I am 3
Notes
The target element must have a parent node, otherwise the wrapping operation will fail.
const $el = $(`
<div>
<div id="target"></div>
</div>
`);
$el.wrap("<div>new div</div>"); // Error: no parent element, cannot wrap
$el.$('#target').wrap("<div>new div</div>"); // Correct: has parent element
Please note, do not operate inside template components such as o-fill or o-if.