Skip to the content.

$.fn.clone([withDataAndEvents [, deepWithDataAndEvents]])

Make a deep copy of every element in the collection. By default the copy is data-and-events free; opt in to copying jQuery-style data() values and bound event handlers.

Signatures

clone(withDataAndEvents?: boolean, deepWithDataAndEvents?: boolean | null): this;

Parameters

Returns

A new Dabby collection wrapping the cloned elements.

Examples

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

// Plain copy — like Element.cloneNode(true)
const $copy = $(".card").clone();
import $ from "dabbyjs";
import "dabbyjs/manipulation/clone/clone";

// Copy data and events too
$(".widget").clone(true, true).appendTo("#stage");

See also