35

My HTML is below. I need to get the selected value (Scheduled) using the <select> tag. How can this be done using jQuery?

<select id="availability" style="display: none;">
  <option value="Available">Available</option>
  <option selected="selected" value="Scheduled">Scheduled</option>
  <option value="Unavailable">Unavailable</option>
</select>

I did a jQuery("#availability") to get the select tag, but I do not know how to get the selected options' value.

Keavon
  • 6,837
  • 9
  • 51
  • 79
bragboy
  • 34,892
  • 30
  • 114
  • 171
  • 1
    Similar question - http://stackoverflow.com/questions/1643227/jquery-get-selected-text-from-dropdownlist – JasCav Aug 18 '10 at 15:00

6 Answers6

63

Try:

jQuery("#availability option:selected").val();

Or to get the text of the option, use text():

jQuery("#availability option:selected").text();

More Info:

Sarfraz
  • 377,238
  • 77
  • 533
  • 578
11

The above solutions didn't work for me. Here is what I finally came up with:

$( "#ddl" ).find( "option:selected" ).text();           // Text
$( "#ddl" ).find( "option:selected" ).prop("value");    // Value
Mahdi
  • 9,247
  • 9
  • 53
  • 74
8
$("#availability option:selected").text();

This will give you the text value of your dropdown list. You can also use .val() instead of .text() depending on what you're looking to get. Follow the link to the jQuery documentation and examples.

JasCav
  • 34,458
  • 20
  • 113
  • 170
5

I have gone through all the answers provided above. This is the easiest way which I used to get the selected value from the drop down list

$('#searchType').val() // for the value

minura
  • 51
  • 1
  • 2
3
$('#availability').find('option:selected').val() // For Value 
$('#availability').find('option:selected').text() // For Text
or 
$('#availability option:selected').val() // For Value 
$('#availability option:selected').text() // For Text
1

Hello guys i am using this technique to get the values from the selected dropdown list and it is working like charm.

var methodvalue = $("#method option:selected").val(); 
Hiren Gohel
  • 4,942
  • 6
  • 29
  • 48