views:

11086

answers:

6

hello,

How can I get asp dropdownlist selected text in Jquery, not selected value/

+12  A: 

Try this:

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

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

$("[id*='MyDropDownId'] :selected")
kgiannakakis
+33  A: 
$("#yourdropdownid option:selected").text();
rahul
A: 

Also, should your dropdownlist have a size of 1 (one), meaning it only displays one thing at a time, you can just use:

$("#dropdownlistID").text();

However, the answer provided by phoenix is the sure-fire way.

Anthony M. Powers
That will return the entire text of all of the options in the drop-down, not just the selected item's text (even if you have a drop down list displaying just one item at a time).
Scott Mitchell
A: 

you can get selected text of a dropdown using jquery by this: $("select[id$='YourDropDown'] :selected").text();

it is fully tested in IE 8, FireFox 3.5.2 and google chorme.

Muhammad Maqbool
A: 

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.

Zarni
A: 

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.

Zarni