Ascherer
Ascherer

Reputation: 8093

Jquery mouseover firing click

Ive got a select menu and i want on mouseover to fire a click event,

I've got this

$('.selectMenu').live('mouseover', function() { $(this).click(); });

but it doesnt seem to be grabbing the right values. Any ideas how to fix this?

Upvotes: 1

Views: 2648

Answers (2)

Cody O'Dell
Cody O'Dell

Reputation: 191

Maybe try:

$('.selectMenu').live('mouseover', function() { $(this).trigger('click'); });

Upvotes: 2

Ender
Ender

Reputation: 15231

I have some experience with this, as I was at one point tasked with making the fgMenu (which is made by Filament Group, the same group as the people who make the selectmenu plugin you are using).

The problem is that this plug-in creates elements which are then substituted for your original <select>, so monitoring for events on that original element will not help you. In my case, I had to modify the plug-in source to change the triggering event from click to hover.

Looking at the current source of the plug-in (which you can find here) and using some knowledge of how the rest of jQueryUI works, you may be able to invoke the open of the menu by doing something like this:

$('.selectMenu').live('mouseover', function() { $(this).selectmenu('open'); });

As a disclaimer, I haven't verified that this actually works, but it's the best guess I can make.

Upvotes: 1

Related Questions