Advertisement
Advertisement


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


Question

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

2020/01/17
1
2322
1/17/2020 5:13:18 PM

Accepted Answer

$("#yourdropdownid option:selected").text();
2009/10/29
3803
10/29/2009 12:05:38 PM

Try this:

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

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

$("[id*='MyDropDownId'] :selected")
2009/10/29

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.

2015/02/28

If you already have the dropdownlist available in a variable, this is what works for me:

$("option:selected", myVar).text()

The other answers on this question helped me, but ultimately the jQuery forum thread $(this + "option:selected").attr("rel") option selected is not working in IE helped the most.

Update: fixed the above link

2016/05/12

This works for me

$("#dropdownid").change(function() {
    alert($(this).find("option:selected").text());
});

If the element created dynamically

$(document).on("change", "#dropdownid", function() {
    alert($(this).find("option:selected").text());
});
2017/08/01

$("option:selected", $("#TipoRecorde")).text()
2012/01/17

Source: https://stackoverflow.com/questions/1643227
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]