Retrieve dropdown list’s selected text in jQuery

Written by stevey on April 11th, 2011

Often times there is need to access a DropDown list control’s selected text from client side; for example, this server control has a server id “ddlSubject”, how would you access its selected text using jquery? I thought this was trivial, using $(“[id$=’ddlSubject’]”).text() would do, as $(“[id$=’ddlSubject’]”).val() I knew would give me the selected value. Wrong!!. As matter of fact, $(“[id$=’ddlSubject’]”).text() returned all the option texts, not just the selected text.

Well, as it turned out, what’s really working is to use $(“[id$=’ddlSubject’] option:selected”).text();


Leave a Comment