I know I can get the value using $("#dropdown").val()
does anybody know how i get the label?
Cheers
var text = $("#dropdown").find("option:selected").text();
which is the same as
var text = $("#dropdown option:selected").text();
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')
Use the :selected
selector (to get the selected <option>
) and get the .text()
, for example:
$("#dropdown :selected").text()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With