Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 447
haddar Avatar asked Oct 29 '09 12:10

haddar


People also ask

How do you get the text value of a selected option in jQuery?

Or to get the text of the option, use text() : $var = jQuery("#dropdownid option:selected"). text(); alert ($var);

How can I get the selected value of a drop down list with jQuery?

Use the jQuery: selected selector in combination with val () method to find the selected option value in a drop-down list.


2 Answers

$("#yourdropdownid option:selected").text(); 
like image 98
rahul Avatar answered Oct 07 '22 20:10

rahul


Try this:

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

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

$("[id*='MyDropDownId'] :selected") 
like image 32
kgiannakakis Avatar answered Oct 07 '22 20:10

kgiannakakis