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) {
//??
});
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) {
//??
});
event.target.id
is the objectevent.target.value
is the new valueJust access the
selectedIndex
property on the select element (this
object in the event handler) to get the option index.Either of these will work:
find by :selected pseudo selector in descendants
get first selected value
pure javascript, use the selectedIndex property