How can I get the text of the selected item from a dropdown using jQuery?
1 Answer
Using the following URL, I came up with this solution:
http://www.mail-archive.com/[email protected]/msg17717.html
$("#myDropdown option:selected").text()
Not sure if this is the best solution, but it seems to work great.
2 Comments
Peter Bailey
using the > selector is overkill and would actually break the script if you used
<optgroup> elements. Just make it #myDropdown option:selected intead.John B
Great idea! I always seem to forget about the additional elements you can throw inside the select element!