diff --git a/entries/val.xml b/entries/val.xml index 1ba0c365..2aaeeb8e 100644 --- a/entries/val.xml +++ b/entries/val.xml @@ -13,6 +13,7 @@

The .val() method is primarily used to get the values of form elements such as input, select and textarea. When the first element in the collection is a select-multiple (i.e., a select element with the multiple attribute set), it returns an array containing the value of each selected option, or null if no options are selected. When called on an empty collection, it returns undefined.

For selects and checkboxes, you can also use the :selected and :checked selectors to get at values, for example:

+

jQuery 3 changes the behavior of this method to return an empty array if a collection is a select-multiple and no options are selected.


 // Get the value from a dropdown select
 $( "select.foo option:selected").val();
@@ -43,6 +44,8 @@ $.valHooks.textarea = {
 function displayVals() {
   var singleValues = $( "#single" ).val();
   var multipleValues = $( "#multiple" ).val() || [];
+  // When using jQuery 3:
+  // var multipleValues = $( "#multiple" ).val()
   $( "p" ).html( "Single: " + singleValues +
     " Multiple: " + multipleValues.join( ", " ) );
 }