Skip to content

Commit a7997d0

Browse files
committed
Fix documentation for .val()
1 parent 93110b7 commit a7997d0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

entries/val.xml

Lines changed: 2 additions & 2 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
}

0 commit comments

Comments
 (0)