You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: entries/val.xml
+4-4
Original file line number
Diff line number
Diff line change
@@ -13,9 +13,9 @@
13
13
<longdesc>
14
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 called on an empty collection, it returns <code>undefined</code>.</p>
15
15
<p>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), <code>.val()</code> returns an array containing the value of each selected option. <strong>As of jQuery 3.0</strong>, if no options are selected, it returns an empty array; <strong>prior to jQuery 3.0</strong>, it returns <code>null</code>.</p>
16
-
<p>For selects and checkboxes, you can also use the <ahref="/selected-selector/">:selected</a> and <ahref="/checked-selector/">:checked</a> selectors to get at values, for example:</p>
17
-
<p><strong>jQuery 3</strong> changes the behavior of this method to return an empty array if a collection is a <code>select-multiple</code> and no options are selected.</p>
16
+
<p>For selects and checkboxes, you can also use the <ahref="/selected-selector/">:selected</a> and <ahref="/checked-selector/">:checked</a> selectors to get at values. For example:</p>
<p><strong>Note: </strong> At present, using <code>.val()</code> on textarea elements strips carriage return characters from the browser-reported value. When this value is sent to the server via XHR, however, carriage returns are preserved (or added by browsers which do not include them in the raw value). A workaround for this issue can be achieved using a valHook as follows:</p>
32
+
<p><strong>Note: </strong> At present, using <code>.val()</code> on <code><textarea></code> elements strips carriage return characters from the browser-reported value. When this value is sent to the server via XHR, however, carriage returns are preserved (or added by browsers which do not include them in the raw value). A workaround for this issue can be achieved using a valHook as follows:</p>
33
33
</div>
34
34
<pre><code>
35
35
$.valHooks.textarea = {
@@ -46,7 +46,7 @@ function displayVals() {
46
46
var singleValues = $( "#single" ).val();
47
47
var multipleValues = $( "#multiple" ).val() || [];
0 commit comments