Skip to content

Commit 557e358

Browse files
committed
Document using any $.fn method for jQuery() 2nd arg
Fixes jquery#95
1 parent 6a71ad9 commit 557e358

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

entries/jQuery.xml

+10-3
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ $foo.triggerHandler('eventName'); // also logs 'eventName was called'
145145
<desc>A string defining a single, standalone, HTML element (e.g. &lt;div/&gt; or &lt;div&gt;&lt;/div&gt;).</desc>
146146
</argument>
147147
<argument name="props" type="PlainObject">
148-
<desc>An map of attributes, events, and methods to call on the newly-created element.</desc>
148+
<desc>A map of attributes, events, and methods to call on the newly-created element.</desc>
149149
</argument>
150150
</signature>
151151
<desc>Creates DOM elements on the fly from the provided string of raw HTML.</desc>
@@ -168,7 +168,14 @@ var el = $('1&lt;br/&gt;2&lt;br/&gt;3'); // returns [&lt;br&gt;, "2", &lt;br&gt;
168168
el = $('1&lt;br/&gt;2&lt;br/&gt;3 &gt;'); // returns [&lt;br&gt;, "2", &lt;br&gt;, "3 &amp;gt;"]
169169
</code></pre>
170170
<p>This behaviour is expected. </p>
171-
<p>As of jQuery 1.4, the second argument to <code>jQuery()</code> can accept a map consisting of a superset of the properties that can be passed to the <a href="/attr">.attr()</a> method. Furthermore, any <a href="/category/events/">event type</a> can be passed in, and the following jQuery methods can be called: <a href="/val">val</a>, <a href="/css">css</a>, <a href="/html">html</a>, <a href="/text">text</a>, <a href="/data">data</a>, <a href="/width">width</a>, <a href="/height">height</a>, or <a href="/offset">offset</a>. The name <code>"class"</code> must be quoted in the map since it is a JavaScript reserved word, and <code>"className"</code> cannot be used since it is not the correct attribute name. </p>
171+
<p>As of jQuery 1.4, the second argument to <code>jQuery()</code> can accept a plain object consisting of a superset of the properties that can be passed to the <a href="/attr">.attr()</a> method. Furthermore, any <a href="/category/events/">event type</a> can be passed in, and the following jQuery methods can be called: <a href="/val">val</a>, <a href="/css">css</a>, <a href="/html">html</a>, <a href="/text">text</a>, <a href="/data">data</a>, <a href="/width">width</a>, <a href="/height">height</a>, or <a href="/offset">offset</a>.</p>
172+
<p><strong>As of jQuery 1.8</strong>, any jQuery instance method (a method of <code>jQuery.fn</code>) can be used as a property of the object passed to the second parameter:</p>
173+
<pre><code>
174+
$( "<div></div>", {
175+
append: "<span>hello</span>"
176+
}).appendTo( "body" );
177+
</code></pre>
178+
<p>The name <code>"class"</code> must be quoted in the map since it is a JavaScript reserved word, and <code>"className"</code> cannot be used since it is not the correct attribute name. </p>
172179
<p><strong>Note:</strong> Internet Explorer will not allow you to create an <code>input</code> or <code>button</code> element and change its type; you must specify the type using <code>'&lt;input type="checkbox" /&gt;'</code> for example. A demonstration of this can be seen below:</p>
173180
<p>Unsupported in IE:</p>
174181
<pre><code>
@@ -230,4 +237,4 @@ $('&lt;input type="text" /&gt;').attr({
230237
<category slug="version/1.0"/>
231238
<category slug="version/1.4"/>
232239
</entry>
233-
</entries>
240+
</entries>

0 commit comments

Comments
 (0)