javascript tutorial - [Solved-5 Solutions] Get selected text from a drop-down list using query - javascript - java script - javascript array
Problem:
How can we get a drop-down list selected text in jQuery, not using the selected value ?
Solution 1:
$("#yourdropdownid option:selected").text();
click below button to copy the code. By JavaScript tutorial team
Solution 2:
Try this:
$("#myselect :selected").text();
click below button to copy the code. By JavaScript tutorial team
For an ASP.NET dropdown we can use the following selector:
$("[id*='MyDropDownId'] :selected")
click below button to copy the code. By JavaScript tutorial team
Solution 3:
The answers posted here, for example,
$('#yourdropdownid option:selected').text();
click below button to copy the code. By JavaScript tutorial team
didn't work for me, but this did:
$('#yourdropdownid').find('option:selected').text();
click below button to copy the code. By JavaScript tutorial team
It is possibly an older version of jQuery.
Solution 4:
If we already have the dropdownlist available in a variable, this is what works for me:
$("option:selected", myVar).text()
click below button to copy the code. By JavaScript tutorial team
Solution 5:
$("option:selected", $("#TipoRecorde")).text()