Skip to the content.

$.fn.wrapAll(html)

Wrap every item in the collection together with a single shared wrapper.

Unlike wrap, only one copy of the wrapper is inserted; all items are gathered inside its deepest descendant in their original DOM order. The wrapper is inserted at the position of the first item in the collection.

Signatures

wrapAll(html: Selector | ((this: Element) => Selector)): this;

Parameters

Returns

The original Dabby collection for chaining.

Examples

import $ from "dabbyjs";
import "dabbyjs/manipulation/wrapall/wrapall";

// Group every chip into a single shared row
$(".chip").wrapAll("<div class='chip-row'></div>");
import $ from "dabbyjs";
import "dabbyjs/manipulation/wrapall/wrapall";

// Wrapper with nested elements — items end up in the deepest descendant
$(".error-message").wrapAll("<div class='alert'><div class='alert-body'></div></div>");

See also