mootools
Everyone loves the MooTools Accordion plugin but I get a lot of requests from readers asking me how to make each accordion item open when the user hovers over the item instead of making the user click. You have two options: hack the original plugin or simply fire the click event when the mouse enters the toggler. My vote is for option two -- here's how to do it.
每个人都喜欢MooTools Accordion插件,但是我收到了很多读者的请求,问我如何在用户将鼠标悬停在手风琴上而不是单击时将其打开。 您有两种选择:破解原始插件或在鼠标进入切换器时简单地触发click事件。 我的投票是第二种方案-这是这样做的方法。
MooTools JavaScript (The MooTools JavaScript)
//make the accordion
var accordion = new Accordion($$('.toggler'),$$('.element'), {
opacity: 0,
onActive: function(toggler) { toggler.setStyle('color', '#f30'); },
onBackground: function(toggler) { toggler.setStyle('color', '#000'); }
});
//make it open on hover
$$('.toggler').addEvent('mouseenter', function() { this.fireEvent('click'); });
As easy as it gets -- simply fire the click event when the user's mouse enters the toggler!
尽可能简单-当用户的鼠标进入切换器时只需触发click事件!
If you aren't familiar with the MooTools Accordion, click here.
如果您不熟悉MooTools手风琴, 请单击此处。
mootools