|
11 | 11 | </signature>
|
12 | 12 | <desc>Get the current value of the first element in the set of matched elements.</desc>
|
13 | 13 | <longdesc>
|
14 |
| - <p>The <code>.val()</code> method is primarily used to get the values of form elements such as <code>input</code>, <code>select</code> and <code>textarea</code>. When the first element in the collection is a <code>select-multiple</code> (i.e., a <code>select</code> element with the <code>multiple</code> attribute set), it returns an array containing the value of each selected option, or <code>null</code> if no options are selected. When called on an empty collection, it returns <code>undefined</code>.</p> |
| 14 | + <p>The <code>.val()</code> method is primarily used to get the values of form elements such as <code>input</code>, <code>select</code> and <code>textarea</code>. When the first element in the collection is a <code>select-multiple</code> (i.e., a <code>select</code> element with the <code>multiple</code> attribute set), it returns an array containing the value of each selected option, or an empty array if no options are selected. When called on an empty collection, it returns <code>undefined</code>.</p> |
15 | 15 | <p>For selects and checkboxes, you can also use the <a href="/selected-selector/">:selected</a> and <a href="/checked-selector/">:checked</a> selectors to get at values, for example:</p>
|
16 | 16 | <pre><code>
|
17 | 17 | // Get the value from a dropdown select
|
@@ -42,7 +42,7 @@ $.valHooks.textarea = {
|
42 | 42 | <code><![CDATA[
|
43 | 43 | function displayVals() {
|
44 | 44 | var singleValues = $( "#single" ).val();
|
45 |
| - var multipleValues = $( "#multiple" ).val() || []; |
| 45 | + var multipleValues = $( "#multiple" ).val(); |
46 | 46 | $( "p" ).html( "<b>Single:</b> " + singleValues +
|
47 | 47 | " <b>Multiple:</b> " + multipleValues.join( ", " ) );
|
48 | 48 | }
|
@@ -115,8 +115,8 @@ $( "input" )
|
115 | 115 | <added>1.4</added>
|
116 | 116 | <argument name="function" type="Function">
|
117 | 117 | <argument name="index" type="Integer" />
|
118 |
| - <argument name="value" type="String" /> |
119 |
| - <return type="String" /> |
| 118 | + <argument name="value" type="String" /> |
| 119 | + <return type="String" /> |
120 | 120 | <desc>A function returning the value to set. <code>this</code> is the current element. Receives the index position of the element in the set and the old value as arguments.</desc>
|
121 | 121 | </argument>
|
122 | 122 | </signature>
|
|
0 commit comments