mootools_MooTools制作的原型Element.on

mootools

Prototype 1.7RC1 was released on Monday. While the big news with this release appears to be the implementation of John Resig's Sizzle selector engine, what caught my eye was the new on method. This new Element.on method is very similar to Prototype's Element.observe method but with a few enhancements (event relaying, event stop). While I don't necessarily care about the enhancements, I simply love that the event method is called "on." Using "on" as the method name makes it sound more like the event itself. Here's how easy it is to use "on" instead of "addEvent" for your events.

原型1.7RC1于周一发布 。 尽管此版本的重大新闻似乎是John Resig的Sizzle选择器引擎的实现,但引起我注意的是新的on方法。 这个新的Element.on方法与Prototype的Element.observe方法非常相似,但具有一些增强功能(事件中继,事件停止)。 尽管我不一定关心增强功能,但我只是喜欢将事件方法称为“ on”。 使用“ on”作为方法名称会使它听起来更像事件本身。 这是为事件使用“ on”而不是“ addEvent”是多么容易。

MooTools JavaScript (The MooTools JavaScript)

/* the directive */
Element.alias('addEvent','on');

/* the usage */
$('myElement').on('click',fn);

Using on instead of addEvent is as easy as a quick MooTools Element.alias directive.

使用on代替addEvent就像快速的MooTools Element.alias指令一样容易。

It's weird that I like "on" so much considering a generally don't like jQuery's css and attr methods. Oh well. Congrats to the Prototype team for their impending release.

考虑到一般不喜欢jQuery的css和attr方法,我非常喜欢“ on”,这很奇怪。 那好吧。 祝贺原型团队即将发布。

翻译自: https://davidwalsh.name/element-on

mootools

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值