简体   繁体   中英

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?

也许试试:

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM