How (using Javascript or jQuery) can I detect when a value has been selected from a select box, even if it’s the same option as was previously selected (i.e. no change event is fired).
Mainly I need this for mouse interaction, but a solution that works for keyboard too would be handy.
The only solution I found workable is to cause
changeevent by setting the value ofselectto some other onmousedown. In the markup I created one extra option (i.e. the first child) and made it hidden (hides perfectly in Chrome/FF/Safari, IE as usual). So it looks fine.Then using jQuery we bind
changeandmousedownevents in a way that whenmousedowntriggers,selectresets its value to the value of the hidden option.DEMO: http://jsfiddle.net/LzNrS/
UPDATE: In order to preserve the selected value when user has clicked on
selectbut decided not the choose anything, we can modify the code a bit addingblurevent and updatingmousedown.DEMO: http://jsfiddle.net/LzNrS/1/