I want to fire a click event(not change event) on select option tags. Click event on select option tag only works in firefox not in google chrome. I have spend a lot of time to resolve this issue still not successfull. Anyone can help me to resolve this problem. Thanx in advance.
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
Try editing the
onclick
function of theselect
tag to call to theoption
tag'sonclick
. The problem now is that it may call twice in FireFox.To see in action ->
Also, the problem with this is that the
onclick
is fired once for clicking the option and another for selecting (then firefox comes around for another). So, the best way I found to patch this is to change it to anonchange
for theselect
tag.But sadly that only gets rid of the initial click, not FireFox's correct way of clicking...
So, if we modify our
getSelectedOption
function to check if the browser is chrome then we can cover our selves!Our new function can look like the following...
Mix everything together!