I am currently using addEventListener on a select:
<select>
<option value="Apple">Mac</option>
<option value="Microsoft">Windows</option>
</select>
document.querySelector("select").addEventListener("change",function(ev){
//do something here...
}, false);
But I can’t figure out how to get the original element from event.
PS: I don’t want to do this:
<select onchange="func(event,this)">
This will only mess up the HTML…
The element that caused the event is automatically assigned to
thisin the event handler. It’s also in the event data structure which is passed to theaddEventListener()callback and in your example isev.target.You can see all the members of the event object here.