$.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
withDataAndEvents(boolean, optional) — whentrue, copies data values set via$.fn.data()and event handlers bound via$.fn.on()to the cloned root element. Defaults tofalse.deepWithDataAndEvents(boolean | null, optional) — whentrue, also copies data and events from descendants. Defaults to the value ofwithDataAndEvents. Passnullto inherit the first argument explicitly.
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");