博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mootools_在MooTools 1.2.3中实现Element.hasEvent
阅读量:2512 次
发布时间:2019-05-11

本文共 1044 字,大约阅读时间需要 3 分钟。

mootools

MooTools allows you to easily add event listeners to elements using the addEvent and removeEvent methods. One thing MooTools doesn't have is a hasEvent method which will check an element's list of listeners to see if the element has been assigned a specific function per event. I experimented with implementing this functionality and believe I've found the best solution.

MooTools允许您使用addEvent和removeEvent方法轻松地将事件侦听器添加到元素。 MooTools没有的一件事是hasEvent方法,该方法将检查元素的侦听器列表以查看是否为每个事件为元素分配了特定功能。 我尝试实现此功能,并相信找到了最佳解决方案。

MooTools JavaScript (The MooTools JavaScript)

Element.implement({	hasEvent: function(eventType,fn) {		//get the element's events		var myEvents = this.retrieve('events');		//can we shoot this down?		return myEvents && myEvents[eventType] && (fn == undefined || myEvents[eventType].keys.contains(fn));	}});

The code is quite short. I can't provide a great use case for implementing this in the MooTools Core but it's a lovely little snippet to have at your disposal.

代码很短。 我无法提供在MooTools Core中实现此功能的绝佳用例,但是您可以随意使用它。

翻译自:

mootools

转载地址:http://rvpwd.baihongyu.com/

你可能感兴趣的文章
VC++使用Pro*CC++
查看>>
前端角度出发做好SEO需要考虑什么?
查看>>
laravel扩展图片处理Intervention Image
查看>>
【PDF】HTML中嵌入pdf的简单方法
查看>>
java集合系列——Map介绍(七)
查看>>
js导出表格
查看>>
Luogu P1550 [USACO08OCT]打井Watering Hole
查看>>
第7章 插件的使用和写法
查看>>
3283
查看>>
嘉为科技获得腾讯投资,拓展企业级IT运营管理市场
查看>>
java得到日期相减的天数
查看>>
安装denyhosts3.1版本报错如下
查看>>
12.1.2: How to Modify and Enable The Configurable Home Page Delivered Via 12.1.2 (Doc ID 1061482.1)
查看>>
Understanding Item Import and Debugging Problems with Item Import (Doc ID 268968.1)
查看>>
Alpha版总结会议
查看>>
Java--面试通关要点
查看>>
iOS 消息推送原理
查看>>
随笔1
查看>>
Codeforces 731 C.Socks-并查集+STL(vector+map)
查看>>
洛谷 P3383 【模板】线性筛素数-线性筛素数(欧拉筛素数)O(n)基础题贴个板子备忘...
查看>>