Skip to content

Commit 76a2669

Browse files
committed
before(): Remove note about disconnected DOM nodes and improve some wording.
Refs gh-559
1 parent 8b4faab commit 76a2669

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

entries/before.xml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
<return>
2626
<type name="htmlString"/>
2727
<type name="Element"/>
28-
<type name="jQuery"/>
29-
</return>
28+
<type name="jQuery"/>
29+
</return>
3030
<desc>A function that returns an HTML string, DOM element(s), or jQuery object to insert before each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, <code>this</code> refers to the current element in the set.
3131
</desc>
3232
</argument>
@@ -47,7 +47,7 @@
4747
</signature>
4848
<desc>Insert content, specified by the parameter, before each element in the set of matched elements.</desc>
4949
<longdesc>
50-
<p>The <code>.before()</code> and <code><a href="/insertBefore/">.insertBefore()</a></code> methods perform the same task. The major difference is in the syntax-specifically, in the placement of the content and target. With <code>.before()</code>, the selector expression preceding the method is the container before which the content is inserted. With <code>.insertBefore()</code>, on the other hand, the content precedes the method, either as a selector expression or as markup created on the fly, and it is inserted before the target container.</p>
50+
<p>The <code>.before()</code> and <code><a href="/insertBefore/">.insertBefore()</a></code> methods perform the same task. The major difference is in the syntaxspecifically, in the placement of the content and target. With <code>.before()</code>, the content to be inserted comes from the method's argument: <code>$(target).before(contentToBeInserted)</code>. With <code>.insertBefore()</code>, on the other hand, the content precedes the method and is inserted before the target, which in turn is passed as the <code>.insertBefore()</code> method's argument: <code>$(contentToBeInserted).insertBefore(target)</code>.</p>
5151
<p>Consider the following HTML:</p>
5252
<pre><code>
5353
&lt;div class="container"&gt;
@@ -83,11 +83,6 @@ $( ".container" ).before( $( "h2" ) );
8383
&lt;/div&gt;
8484
</code></pre>
8585
<p><strong>Important</strong>: If there is more than one target element, however, cloned copies of the inserted element will be created for each target except for the last one.</p>
86-
<p>In jQuery 1.4, <code>.before()</code> and <code>.after()</code> will also work on disconnected DOM nodes:</p>
87-
<pre><code>
88-
$( "&lt;div&gt;" ).before( "&lt;p&gt;&lt;/p&gt;" );
89-
</code></pre>
90-
<p>The result is a jQuery set that contains a paragraph and a div (in that order).</p>
9186
<h4 id="additional-arguments">Additional Arguments</h4>
9287
<p>Similar to other content-adding methods such as <code><a href="/prepend/">.prepend()</a></code> and <code><a href="/after/">.after()</a></code>, <code>.before()</code> also supports passing in multiple arguments as input. Supported input includes DOM elements, jQuery objects, HTML strings, and arrays of DOM elements.</p>
9388
<p>For example, the following will insert two new <code>&lt;div&gt;</code>s and an existing <code>&lt;div&gt;</code> before the first paragraph:</p>

0 commit comments

Comments
 (0)