How do I trigger a event in jQuery when any item in a select box is selected?
I want to freeze animations on a page while a select box is chosen and then restar开发者_高级运维t them when the select box is released. It's easy to freeze them with .focus()
but I'm having trouble after this.
If I use .blur()
, this doesn't work when an item in the select box is selected as it retains focus. If I use .change()
, this doesn't work if the item selected isn't changed. If I use .mouseup()
this overrides the .focus()
that was used at the beginning.
The closest I can get is to use a combination of .blur()
and .change()
. This catches all events except for selecting the item that was already selected. Surely there's an event for this that I can't find.
Have you looked into using the click() event?
That said, you may want to consider building your own UI widget to emulate what a select box does, since it seems like the native select box isn't quite working out for you.
Are you trying to trigger on mousedown
and mouseup
? Would those two events work better?
精彩评论