Skip to content

Commit d84b9cf

Browse files
committed
Ref gh-240, note newly pushy behavior of append-target methods.
1 parent 2ae644c commit d84b9cf

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

entries/appendTo.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,15 @@
4040
<p>We can also select an element on the page and insert it into another:</p>
4141
<pre><code>$('h2').appendTo($('.container'));
4242
</code></pre>
43-
<p>If an element selected this way is inserted into a single location elsewhere in the DOM, it will be moved into the target (not cloned):</p>
43+
<p>If an element selected this way is inserted into a single location elsewhere in the DOM, it will be moved into the target (not cloned) and a new set consisting of the inserted element is returned:</p>
4444
<pre><code>&lt;div class="container"&gt;
4545
&lt;div class="inner"&gt;Hello&lt;/div&gt;
4646
&lt;div class="inner"&gt;Goodbye&lt;/div&gt;
4747
&lt;h2&gt;Greetings&lt;/h2&gt;
4848
&lt;/div&gt;
4949
</code></pre>
5050
<p>If there is more than one target element, however, cloned copies of the inserted element will be created for each target after the first, and that new set (the original element plus clones) is returned.</p>
51+
<p><strong>Before jQuery 1.9,</strong> the append-to-single-element case did not create a new set, but instead returned the original set which made it difficult to use the <code>.end()</code> method reliably when being used with an unknown number of elements.</p>
5152
</longdesc>
5253
<example>
5354
<desc>Append all spans to the element with the ID "foo" (Check append() documentation for more examples)</desc>

entries/insertAfter.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@
3232
&lt;/div&gt;</code></pre>
3333
<p>We can also select an element on the page and insert it after another:</p>
3434
<pre><code>$('h2').insertAfter($('.container'));</code></pre>
35-
<p>If an element selected this way is inserted into a single location elsewhere in the DOM, it will be moved after the target (not cloned):</p>
35+
<p>If an element selected this way is inserted into a single location elsewhere in the DOM, it will be moved after the target (not cloned) and a new set consisting of the inserted element is returned:</p>
3636
<pre><code>&lt;div class="container"&gt;
3737
&lt;div class="inner"&gt;Hello&lt;/div&gt;
3838
&lt;div class="inner"&gt;Goodbye&lt;/div&gt;
3939
&lt;/div&gt;
4040
&lt;h2&gt;Greetings&lt;/h2&gt;</code></pre>
4141
<p>If there is more than one target element, however, cloned copies of the inserted element will be created for each target after the first, and that new set (the original element plus clones) is returned.</p>
42+
<p><strong>Before jQuery 1.9,</strong> the append-to-single-element case did not create a new set, but instead returned the original set which made it difficult to use the <code>.end()</code> method reliably when being used with an unknown number of elements.</p>
4243
</longdesc>
4344
<example>
4445
<desc>Insert all paragraphs after an element with id of "foo". Same as $("#foo").after("p")</desc>

entries/insertBefore.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@
3232
&lt;/div&gt;</code></pre>
3333
<p>We can also select an element on the page and insert it before another:</p>
3434
<pre><code>$('h2').insertBefore($('.container'));</code></pre>
35-
<p>If an element selected this way is inserted into a single location elsewhere in the DOM, it will be moved before the target (not cloned):</p>
35+
<p>If an element selected this way is inserted into a single location elsewhere in the DOM, it will be moved before the target (not cloned) and a new set consisting of the inserted element is returned:</p>
3636
<pre><code>&lt;h2&gt;Greetings&lt;/h2&gt;
3737
&lt;div class="container"&gt;
3838
&lt;div class="inner"&gt;Hello&lt;/div&gt;
3939
&lt;div class="inner"&gt;Goodbye&lt;/div&gt;
4040
&lt;/div&gt;</code></pre>
4141
<p>If there is more than one target element, however, cloned copies of the inserted element will be created for each target after the first, and that new set (the original element plus clones) is returned.</p>
42+
<p><strong>Before jQuery 1.9,</strong> the append-to-single-element case did not create a new set, but instead returned the original set which made it difficult to use the <code>.end()</code> method reliably when being used with an unknown number of elements.</p>
4243
</longdesc>
4344
<example>
4445
<desc>Insert all paragraphs before an element with id of "foo". Same as $("#foo").before("p")</desc>

0 commit comments

Comments
 (0)