Reputation: 7688
How can I get the current <select>
text? I mean if I have selected the <option name="me">ME</option>
how can I get its text?
Because the way I'm trying, returns all the texts inside the <select>
$('#action').change(function() {
console.log($(this).text()); //this returns all the texts inside select
Upvotes: 1
Views: 72
Reputation:
$("#" + $(this).attr("id") + " option:selected").text();
would work as well! But please use danish's solution!
Upvotes: 2
Reputation: 484
try this
$('#action').change(function() {
$(this).find(':selected').text();
});
Upvotes: 3
Reputation: 9174
You can get the text of a select by using
$("#action option:selected").text();
Upvotes: 0