I do not see why onfocus='myFunction()' works in a an input, but not in an option, for example:
<input type="text" id="fname" onfocus="myFunction()">
calls myFunction when you click on it or when you tab into it, but:
<select multiple>
<option onfocus="myFunction()">whatever</option>
</select>
Does not work when you step in the option.
Why is this? I cannot find a documentation which says what events work on what elements. I have seen this for a long time, but now I want to know why
EDIT: I am using Chrome.
Please look at the MDM web docs
For onfocus to fire on non-input elements, they must be given the tabindex attribute
So in other terms: give the option with the focus event a tabIndex! The example below should work.
function myFunction() {
console.log("focus");
}
function myFunction2() {
console.log("focus2");
}
<select multiple>
<option tabIndex="0" onfocus="myFunction()">whatever</option>
<option tabIndex="0" onfocus="myFunction2()">whatever2</option>
</select>