Sometimes you need to duplicate an existing DOM element — for example, to add another row to a table, repeat a card template, or copy a form field set. jQuery's .clone() method creates a deep copy of matched elements and all their descendants.
Basic Cloning
Calling .clone() without arguments copies the element and its children but does not copy jQuery event handlers or data. This is the safest default when you just need the markup structure.
Cloning with Events
Pass true as the first argument to also clone all jQuery event handlers and data bound to the element and its descendants: .clone(true). A second true controls whether descendants also receive their handlers — usually you want both.
.clone()— copy markup only.clone(true)— copy markup and handlers on root element.clone(true, true)— copy markup and handlers on all descendants too
After cloning, remember to update any id attributes to keep them unique in the document. IDs must be unique for valid HTML and for jQuery selectors to work predictably.