Say I have an onMouseMove listener which just logs the x and y position of the mouse.
If I expand a select element and move my mouse over the exposed <option>
elements, the onMouseMove event never fires.
I think it might have something to do with this:
http://www.terminally-incoherent.com/blog/2009/01/12/ie-jquery-hovering-and-option-elements/
Does anybody know how to get around this? Specifically, I would like to get an instance of the <option>
element I'm moving over at any given time.
I would prefer not to change the <select>
or <option>
elements as my code is injected by a chrome extension and it would be burdensome to change every page for this reason.
As you suspected, the mouse events do not work on a select/option in Chrome
Possible workarounds might be:
I created an example of the third option here:
http://jsfiddle.net/SNLzA/
This clones the original select and hides the clone. The clone is given a size attribute so that it can react to mouse events. Then, when the original select is clicked we temporarily show the clone which has been styled to sort of look like the options drop down. Then when a user clicks an option, we close the clone and set the value in the original select. A click event listener is attached to the body to close the clone when not on an option.
HTML
CSS
JS