惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
SecWiki News
SecWiki News
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
小众软件
小众软件
C
CERT Recently Published Vulnerability Notes
Jina AI
Jina AI
N
Netflix TechBlog - Medium
GbyAI
GbyAI
IT之家
IT之家
Apple Machine Learning Research
Apple Machine Learning Research
AWS News Blog
AWS News Blog
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
C
Cybersecurity and Infrastructure Security Agency CISA
I
Intezer
T
Tor Project blog
P
Palo Alto Networks Blog
P
Privacy & Cybersecurity Law Blog
P
Privacy International News Feed
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Proofpoint News Feed
T
Tailwind CSS Blog
C
Check Point Blog
Cloudbric
Cloudbric
Y
Y Combinator Blog
The Last Watchdog
The Last Watchdog
Forbes - Security
Forbes - Security
Last Week in AI
Last Week in AI
S
Security Affairs
博客园 - Franky
F
Fortinet All Blogs
量子位
M
MIT News - Artificial intelligence
C
Cisco Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
Stack Overflow Blog
Stack Overflow Blog
S
Secure Thoughts
V
Visual Studio Blog
AI
AI
美团技术团队
B
Blog RSS Feed
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 三生石上(FineUI控件)
阮一峰的网络日志
阮一峰的网络日志
Engineering at Meta
Engineering at Meta
人人都是产品经理
人人都是产品经理
Microsoft Security Blog
Microsoft Security Blog
T
Threatpost
Cyberwarzone
Cyberwarzone

博客园 - everx

CruiseControl.net - 找到的一些文档。分享出来 【摘抄】回归测试(Regression Test) 那就来说说ASP.NET MVC中的Routing吧 ASP.NET MVC - View ASP.NET MVC - Controller(part Ⅱ) ASP.NET MVC - Controller(part Ⅰ) ASP.NET MVC - Model 学一下ASP.NET MVC C# 3.0的新特性 jQuery学习笔记(八) jQuery 学习笔记(七) SilverLight学习之路(四) Silverlight学习之路(三) - everx - 博客园 JQuery学习笔记(六) JQuery学习笔记(五) 初次使用log4net Silverlight学习之路(二) JQuery学习笔记(四) 播下silverlight的种子
JQuery学习笔记(三)
everx · 2008-02-21 · via 博客园 - everx

四、事件

1、浏览器实现的事件模型
DOM Level 0事件处理的实现是将一个handler赋值给元素的属性,如onclick=function(param1, param2){...}。
缺点是一个事件只能有一个处理函数,即最后一个被赋值的处理函数,之前的全部被覆盖
DOM Level 2事件处理的实现是使用方法addEventListener(eventType, listener, useCapture)
eventType是去掉之前元素属性的"on"前缀,即onclick的eventType是click
listener是事件处理函数的引用,第一个参数是event对象
useCapture是指使用捕捉或冒泡方式处理事件,一般为false,即使用冒泡方式
但是IE没有实现DOM Level 2的事件处理模型,不支持捕捉方式,而且使用方法也不同
attachEvent(eventName,handler)
handler没有将event对象作为第一个参数传入,而是使用window.event

2、用JQuery绑定事件处理到元素
bind(eventType,data,listener)    绑定事件到JQuery对象
eventType:事件类型
data:Object类型,用于listener中使用的数据,可省略
listener:处理函数

还可以对事件进行组合,使用namespace的方式
例如:click.myNamespace,这样可以将几个事件处理作为一个单元处理

eventTypeName(listener)   
eventTypeName是指:
blur
change
click
dblclick
error
focus
keydown
keypress
keyup
load
mousedown
mousemove
mouseout
mouseover
mouseup
resize
scroll
select
submit
unload

结果返回包装集

one(eventType,data,listener)    只执行一次绑定的函数
unbind(eventType,listener)    若没有参数则所有的listener都被移除
unbind(event)

3、Event对象实例

Event实例属性

altKey
Set to true if the Alt key was pressed when the event was triggered, false if not. The Alt key is labeled Option on most Mac keyboards.
ctrlKey

Set to true if the Ctrl key was pressed when the event was triggered, false if not. data The value, if any, passed as the second parameter to the bind() command when the handler was established.
keyCode
For keyup and keydown events, this returns the key that was pressed. Note that for alphabetic characters, the uppercase version of the letter will be returned, regardless of whether the user typed an uppercase or lowercase letter. For example, both a and A will return 65. You can use shiftKey to determine which case was entered. For keypress events, use the which property, which is reliable across browsers.
metaKey
Set to true if the Meta key was pressed when the event was triggered, false if not The Meta key is the Ctrl key on PCs and the Command key on Macs.
pageX
For mouse events, specifies the horizontal coordinate of the event relative from the page origin.
pageY
For mouse events, specifies the vertical coordinate of the event relative from the page origin.
relatedTarget
For some mouse events, identifies the element that the cursor left or entered when the event was triggered.
screenX
For mouse events, specifies the horizontal coordinate of the event relative from the screen origin.
screenY
For mouse events, specifies the vertical coordinate of the event relative from the screen origin.
shiftKey
Set to true if the Shift key was pressed when the event was triggered, false if not.
target
Identifies the element for which the event was triggered.
type
For all events, specifies the type of event that was triggered (for example, click). This can be useful if you’re using one event handler function for multiple events.
which
For keyboard events, specifies the numeric code for the key that caused the event, and for mouse events, specifies which button was pressed (1 for left, 2 for middle, 3 for right). This should be used instead of button, which can’t be relied on to function consistently across browsers.

stopPropagation()
preventDefault()

4、用脚本触发事件处理
trigger(eventType)    由于事件触发是从代码产生的,所以没有Event实例,也没有冒泡
eventName()
blur
click
focus
select
submit

toggle(listenerOdd,listenerEven)
listenerOdd    第1、3……次执行的函数
listenerEven    第2、4……次执行的函数

hover(overListener,outListener)