Categories
dom drop-down-menu javascript jquery jquery-selectors

Get selected text from a drop-down list (select box) using jQuery

2462

How can I get the selected text (not the selected value) from a drop-down list in jQuery?

5

3958

$("#yourdropdownid option:selected").text();

4

  • 218

    I think this should be $("#yourdropdownid").children("option").filter(":selected").text() since is() returns a boolean of whether the object matches the selector or not.

    – MHollis

    May 18, 2012 at 14:04


  • 45

    I second the comment about is() returning a boolen; alternatively, use the following small alteration: $(‘#yourdropdownid’).children(“option:selected”).text();

    – scubbo

    Jun 12, 2012 at 14:56


  • 103

    $('select').children(':selected') is the fastest way: jsperf.com/get-selected-option-text

    – Simon

    Apr 24, 2013 at 13:51

  • And if have scape caracteres like \n \t you can add .trim() getting like this: $("#yourdropdownid option:selected").text().trim();

    Apr 22 at 20:39

278

Try this:

$("#myselect :selected").text();

For an ASP.NET dropdown you can use the following selector:

$("[id*='MyDropDownId'] :selected")

0

    232

    The answers posted here, for example,

    $('#yourdropdownid option:selected').text();
    

    didn’t work for me, but this did:

    $('#yourdropdownid').find('option:selected').text();
    

    It is possibly an older version of jQuery.

    0