Skip to content

Commit 07d5e37

Browse files
committed
Fix documentation for .val()
See: #828 jquery/jquery#2562 timmywil/jquery@4319c27
1 parent 93110b7 commit 07d5e37

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

entries/val.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</signature>
1212
<desc>Get the current value of the first element in the set of matched elements.</desc>
1313
<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>
1515
<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>
1616
<pre><code>
1717
// Get the value from a dropdown select
@@ -42,7 +42,7 @@ $.valHooks.textarea = {
4242
<code><![CDATA[
4343
function displayVals() {
4444
var singleValues = $( "#single" ).val();
45-
var multipleValues = $( "#multiple" ).val() || [];
45+
var multipleValues = $( "#multiple" ).val();
4646
$( "p" ).html( "<b>Single:</b> " + singleValues +
4747
" <b>Multiple:</b> " + multipleValues.join( ", " ) );
4848
}
@@ -115,8 +115,8 @@ $( "input" )
115115
<added>1.4</added>
116116
<argument name="function" type="Function">
117117
<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" />
120120
<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>
121121
</argument>
122122
</signature>

0 commit comments

Comments
 (0)