12

I know I can get the value using $("#dropdown").val()

does anybody know how i get the label?

Cheers

jim smith
  • 231
  • 1
  • 3
  • 6
  • possible duplicate of [How to get the text of the selected option of a select using jquery?](http://stackoverflow.com/questions/1391019/how-to-get-the-text-of-the-selected-option-of-a-select-using-jquery) – Felix Kling Oct 01 '10 at 12:12
  • Does this answer your question? [How to get label of select option with jQuery?](https://stackoverflow.com/questions/2175737/how-to-get-label-of-select-option-with-jquery) – Hamza Ali Feb 04 '20 at 05:38

3 Answers3

27
var text = $("#dropdown").find("option:selected").text();

which is the same as

var text = $("#dropdown option:selected").text();
mkoryak
  • 57,086
  • 61
  • 201
  • 257
  • @BBonifield, *Vive la Revolución!* =) @mkoryak, +1 (and not *just* for beating Nick) – David Thomas Oct 01 '10 at 12:14
  • @BBonifield - It's not that hard to be faster anyone really...different people are mapped to different SO servers (IP hash) which have a cache refreshing at staggered intervals...which means one person may never see a question even appear on their unanswered list before it's been answered and upvoted before *that* server's cache refreshes, even constantly refreshing :) – Nick Craver Oct 01 '10 at 12:19
  • 1
    @Nick, uhm, yea, nice theory.. just admit defeat!! ;) – mkoryak Oct 01 '10 at 12:23
  • @mkoryak - It's true :) During the day I don't even see a ton of questions even in the categories I'm most active in, same goes for all users...you just don't realize it unless you look at the all questions by recent list :) (That is, if you *usually* look at "Unanswered" as I do) – Nick Craver Oct 01 '10 at 12:26
  • this still only gets the text, not the label – bicycle Dec 19 '12 at 12:24
8

Use the :selected selector (to get the selected <option>) and get the .text(), for example:

$("#dropdown :selected").text()
Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155
4

All these answers fail to answer the question. He's talking about the label, not the text. Label is a valid attribute of the option (Specifies a shorter label for an option). See http://www.w3schools.com/tags/tag_option.asp

To get the label use: $('#dropdown').find("option:selected").attr('label')

bicycle
  • 8,315
  • 9
  • 52
  • 72