Reputation: 5032
I want to call a method when the user click on a select, just before the option-list appear. ( Click events are called after)
I want to do it in order to modify the option-list just before the user can see it.
Any idea?
Upvotes: 0
Views: 294
Reputation: 207923
Both the mousedown and focus events would allow you to modify the options prior to opening the drop down list.
var el = document.getElementById("sel");
// Change focus to click or mousedown to see the difference
el.addEventListener("focus", modifyOpt, false);
function modifyOpt() {
var opts = sel.options;
opts[0].innerHTML = '2';
}
<select id="sel">
<option>1</option>
</select>
Upvotes: 2