wrap
The wrap method wraps the target element with another element. Before performing the wrap operation, the initialization of the $ method is automatically executed, so you can directly specify an 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 within template components such as o-fill or o-if.