hello,
How can I get asp dropdownlist selected text in Jquery, not selected value/
hello,
How can I get asp dropdownlist selected text in Jquery, not selected value/
Try this:
$("#myselect :selected").text();
For an ASP.NET dropdown you can use the following selector:
$("[id*='MyDropDownId'] :selected")
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.
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.
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.
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.