From 1ce8d2b00231d8200864fd6ded83e8fc11f5d078 Mon Sep 17 00:00:00 2001
From: Richard Gibson The The For selects and checkboxes, you can also use the :selected and :checked selectors to get at values, for example:.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
. .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.
// Get the value from a dropdown select