Reputation: 4345
From jquery docs:
$( "#myselect" ).val();
Will give the value and for text following will suffice:
$( "#myselect option:selected" ).text();
How can text be extracted when all one has is the this
reference?
$(document.body).on("click", ".lots-of-select-boxes-class", function() {
var value = $(this).val();
var text = HOW-TO-GET-TEXT; // ???
});
Upvotes: 0
Views: 40
Reputation: 57105
var text =$(this).find("option:selected").text();
or
var text =$(this).children("option:selected").text();
Upvotes: 1