Skip to content

Commit b83bd13

Browse files
bedgingtonkswedberg
authored andcommitted
.clone(): Specify which form controls maintain state when cloned.
Fixes jquery#381. Closes jquery#382
1 parent 0b93913 commit b83bd13

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

entries/clone.xml

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
</signature>
1919
<desc>Create a deep copy of the set of matched elements.</desc>
2020
<longdesc>
21-
<p>The <code>.clone()</code> method performs a <em>deep</em> copy of the set of matched elements, meaning that it copies the matched elements as well as all of their descendant elements and text nodes. For performance reasons, the dynamic state of form elements (e.g., user data typed into <code>input</code>, and <code>textarea</code> or user selections made to a <code>select</code>) is not copied to the cloned elements. The clone operation sets these fields to their default values as specified in the HTML.</p>
21+
<p>The <code>.clone()</code> method performs a <em>deep</em> copy of the set of matched elements, meaning that it copies the matched elements as well as all of their descendant elements and text nodes.</p>
22+
<div class="warning">
23+
<p><strong>Note:</strong> For performance reasons, the dynamic state of certain form elements (e.g., user data typed into <code>textarea</code> and user selections made to a <code>select</code>) is not copied to the cloned elements. When cloning <code>input</code> elements, the dynamic state of the element (e.g., user data typed into text inputs and user selections made to a checkbox) is retained in the cloned elements.</p>
24+
</div>
2225
<p>When used in conjunction with one of the insertion methods, <code>.clone()</code> is a convenient way to duplicate elements on a page. Consider the following HTML:</p>
2326
<pre><code>
2427
&lt;div class="container"&gt;

0 commit comments

Comments
 (0)