How can I get the selected text (not the selected value) from a drop-down list in jQuery?
-
13Just my two cents: An "ASP" drop-down is no special; it's just good old HTML. :-) – ankush981 Jun 04 '15 at 06:20
-
One can refer this article: http://javascriptstutorial.com/blog/selecting-dropdown-element-using-javascript-or-jquery/ – Dilip Kumar Yadav Oct 18 '16 at 12:02
-
for vanilla javascript way, see http://stackoverflow.com/a/5947/32453 – rogerdpack Jan 18 '17 at 19:27
-
Just $(this).prop('selected', true); replaced .att to .prop it worked for all browsers – Shahid Hussain Abbasi Jan 12 '19 at 11:13
-
$("#yourdropdownid option:selected").text(); – Ali NajafZadeh Aug 03 '21 at 16:57
35 Answers
$("#yourdropdownid option:selected").text();

- 184,426
- 49
- 232
- 263
-
218I 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 '12 at 14:04
-
45I second the comment about is() returning a boolen; alternatively, use the following small alteration: $('#yourdropdownid').children("option:selected").text(); – scubbo Jun 12 '12 at 14:56
-
104`$('select').children(':selected')` is the fastest way: http://jsperf.com/get-selected-option-text – Simon Apr 24 '13 at 13:51
-
And if have scape caracteres like `\n \t` you can add `.trim()` getting like this: `$("#yourdropdownid option:selected").text().trim();` – Leffa Apr 22 '22 at 20:39
Try this:
$("#myselect :selected").text();
For an ASP.NET dropdown you can use the following selector:
$("[id*='MyDropDownId'] :selected")

- 103,016
- 27
- 158
- 194
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.

- 30,738
- 21
- 105
- 131

- 2,653
- 2
- 17
- 15
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

- 1,341
- 6
- 28
- 54

- 7,733
- 9
- 46
- 57
-
``` ```
Link: https://www.geeksforgeeks.org/how-to-get-selected-text-from-a-drop-down-list-using-jquery/ – Dushyant Singh Jul 22 '22 at 19:47
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());
});

- 3,620
- 1
- 19
- 19
$("#DropDownID").val()
will give the selected index value.

- 16,245
- 11
- 62
- 79

- 693
- 5
- 2
-
40Not exactly the answer to the question, but was useful for me. The question wants the selected text. – Peter Nov 28 '11 at 14:50
-
@Neeraj, thank you for the answer. I discovered that val() != text() and in case when you have more then one value you will get something like.... '\n\tBYELORUSSIAN\n\tCATALAN\n\tCHINESESIMPLIFIED\n\tCHINESETRADITIONAL\n\tCROATIAN\n\tCZECH\n\tDANISH\n\tDUTCH\n\tESPERANTO\n\tESTONIAN\n\tFINNISH\n\tFRENCH\n\tGALICIAN\n\tGERMA' – Roman Denisenko Feb 14 '23 at 09:11
Use this
const select = document.getElementById("yourSelectId");
const selectedIndex = select.selectedIndex;
const selectedValue = select.value;
const selectedText = select.options[selectedIndex].text;
Then you get your selected value and text inside selectedValue
and selectedText
.

- 10,804
- 5
- 49
- 61

- 1,199
- 10
- 10
Various ways
1. $("#myselect option:selected").text();
2. $("#myselect :selected").text();
3. $("#myselect").children(":selected").text();
4. $("#myselect").find(":selected").text();

- 14,325
- 6
- 82
- 89
$("#dropdownID").change(function(){
alert($('option:selected', $(this)).text());
});

- 2,757
- 26
- 37
var someName = "Test";
$("#<%= ddltest.ClientID %>").each(function () {
$('option', this).each(function () {
if ($(this).text().toLowerCase() == someName) {
$(this).attr('selected', 'selected')
};
});
});
That will help you to get right direction. Above code is fully tested if you need further help let me know.
For those who are using SharePoint lists and don't want to use the long generated id, this will work:
var e = $('select[title="IntenalFieldName"] option:selected').text();

- 30,738
- 21
- 105
- 131

- 499
- 1
- 7
- 16
This code worked for me.
$("#yourdropdownid").children("option").filter(":selected").text();

- 2,532
- 3
- 34
- 60
-
Works too! And if have scape caracteres like `\n \t` you can add `.trim()` getting like this: `$("#yourdropdownid").children("option").filter(":selected").text().trim();` – Leffa Apr 22 '22 at 20:39
$("#selectID option:selected").text();
Instead of #selectID
you can use any jQuery selector, like .selectClass
using class.
As mentioned in the documentation here.
The :selected selector works for <option> elements. It does not work for checkboxes or radio inputs; use :checked
for them.
.text() As per the documentation here.
Get the combined text contents of each element in the set of matched elements, including their descendants.
So you can take text from any HTML element using the .text()
method.
Refer the documentation for a deeper explanation.

- 30,738
- 21
- 105
- 131

- 26,128
- 21
- 90
- 126
$("select[id=yourDropdownid] option:selected").text()
This works fine

- 5,152
- 4
- 32
- 39
Select Text and selected value on dropdown/select change event in jQuery
$("#yourdropdownid").change(function() {
console.log($("option:selected", this).text()); //text
console.log($(this).val()); //value
})

- 6,915
- 8
- 26
- 46

- 685
- 1
- 9
- 19
For getting selected value use
$('#dropDownId').val();
and for getting selected item text use this line:
$("#dropDownId option:selected").text();

- 514
- 9
- 19
Try:
$var = jQuery("#dropdownid option:selected").val();
alert ($var);
Or to get the text of the option, use text()
:
$var = jQuery("#dropdownid option:selected").text();
alert ($var);
More Info:

- 1,564
- 16
- 25
Simply try the following code.
var text= $('#yourslectbox').find(":selected").text();
it returns the text of the selected option.

- 582
- 6
- 15
var e = document.getElementById("dropDownId");
var div = e.options[e.selectedIndex].text;

- 1,250
- 15
- 29
$("#dropdown").find(":selected").text();
$("#dropdown :selected").text();
$("#dropdown option:selected").text();
$("#dropdown").children(":selected").text();

- 506
- 6
- 17
Use:
('#yourdropdownid').find(':selected').text();

- 30,738
- 21
- 105
- 131

- 1,658
- 7
- 24
- 33
the following worked for me:
$.trim($('#dropdownId option:selected').html())

- 21,578
- 41
- 164
- 232
In sibling case
<a class="uibutton confirm addClient" href="javascript:void(0);">ADD Client</a>
<input type="text" placeholder="Enter client name" style="margin: 5px;float: right" class="clientsearch large" />
<select class="mychzn-select clientList">
<option value="">Select Client name....</option>
<option value="1">abc</option>
</select>
/*jQuery*/
$(this).siblings('select').children(':selected').text()
$(function () {
alert('.val() = ' + $('#selectnumber').val() + ' AND html() = ' + $('#selectnumber option:selected').html() + ' AND .text() = ' + $('#selectnumber option:selected').text());
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<select id="selectnumber">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
<option value="4">four</option>
</select>
</div>
</form>
</body>
</html>

- 10,100
- 16
- 60
- 102

- 1,635
- 17
- 17
Try
dropdown.selectedOptions[0].text
function read() {
console.log( dropdown.selectedOptions[0].text );
}
<select id="dropdown">
<option value="1">First</option>
<option value="2">Second</option>
</select>
<button onclick="read()">read</button>

- 85,173
- 29
- 368
- 345
If you want the result as a list, then use:
x=[];
$("#list_id").children(':selected').each(function(){x.push($(this).text());})

- 9,708
- 15
- 89
- 144
$("#dropdownid option:selected").text();
if you use asp.net and write
<Asp:dropdownlist id="ddl" runat="Server" />
then you should use
$('#<%=ddl.Clientid%> option:selected').text();

- 934
- 1
- 12
- 27
For multi-selects:
$("#yourdropdownid :selected").map(function(i, v) { return $.trim($(v).text()); }

- 6,696
- 3
- 46
- 36
Just add the below line
$(this).prop('selected', true);
replaced .att to .prop it worked for all browsers.

- 356
- 3
- 18

- 2,508
- 16
- 10
$("#dropdownid").change(function(el) {
console.log(el.value);
});
Or you can use this
$("#dropdownid").change(function() {
console.log($(this).val());
});

- 1,332
- 1
- 13
- 29