mootools_MooTools手风琴:鼠标悬停样式

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手风琴, 请单击此处。

翻译自: https://davidwalsh.name/mootools-accordion-hover-event

mootools

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值