Reputation: 68680
the .click() event doesn't seem to work on select, please see: http://jsfiddle.net/fMTzD/
Even before the options are shown, I need the jQuery click function to do something. Is is possible? I don't mind even if the options are not shown at all.
Thanks
Upvotes: 0
Views: 1452
Reputation: 7076
Another option is wrapping the select
in a span
and using it's click
event:
Markup:
<span id="use-this">
<select>
</select>
</span>
jQuery:
$("#use-this").click(function(){
alert("Select box was clicked");
});
I'd still like to know the reason behind select click event not triggering
Upvotes: 0
Reputation: 21553
I would use onFocus
instead (although onMouseUp
and onMouseDown
are suitable alternatives):
$("select, button").focus(function () {
$(this).hide();
});
See my updates to your jsfiddle.
You cannot use onChange
as that is triggered after the user chooses an option from the dropdown.
Upvotes: 2