From 1ce8d2b00231d8200864fd6ded83e8fc11f5d078 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 26 Dec 2013 10:59:47 -0500 Subject: [PATCH] .val: Be more clear about when null is returned Ref jQuery #14654 --- entries/val.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entries/val.xml b/entries/val.xml index 3d1b96bf..9285a546 100644 --- a/entries/val.xml +++ b/entries/val.xml @@ -11,7 +11,7 @@ Get the current value of the first element in the set of matched elements. -

The .val() method is primarily used to get the values of form elements such as input, select and textarea. In the case of <select multiple="multiple"> elements, the .val() method returns an array containing each selected option; if no option is selected, it returns null.

+

The .val() method is primarily used to get the values of form elements such as input, select and textarea. In the case of select elements, it returns null when no option is selected and an array containing the value of each selected option when there is at least one and it is possible to select more because the multiple attribute is present.

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


 // Get the value from a dropdown select