Reputation: 1115
select.onchange = function() {
this.value;
}
It's easy to retrieve the value but now I need the text of the selected element. How to do it?
Upvotes: 0
Views: 120
Reputation: 5050
//assuming "this" is the select element
if (this.selectedIndex >= 0) {
this.options[this.selectedIndex].text = "some text";
}
Upvotes: 0
Reputation: 75327
(Sorry... put .value before my edit instead of .text by accident 8-)...)
this.options[this.selectedIndex].text
Upvotes: 2