Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
155
rated 0 times [  162] [ 7]  / answers: 1 / hits: 15195  / 15 Years ago, wed, march 17, 2010, 12:00:00

With Mootools, if I attach a change event listener on a <select> how do I access the option that was selected. I would like the actual element and not just the value.



$('select').addEvent('change',function(event) {
//??
});

More From » html-select

 Answers
43

Either of these will work:



find by :selected pseudo selector in descendants



this.getElement(':selected');


get first selected value



this.getSelected()[0];


pure javascript, use the selectedIndex property



this.options[this.selectedIndex];

[#97311] Monday, March 15, 2010, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
skylerselenem

Total Points: 282
Total Questions: 101
Total Answers: 107

Location: Nicaragua
Member since Tue, Dec 8, 2020
4 Years ago
;