Typically useful on anchor elements for which following the link should produce javascript functionality instead of the default action (following the URL).
Function binds mouse click and enter keypress to a specified element, and calls the specified function. The default action (e.g. following the href for an anchor) is prevented.
Release 1.2+ supports binding to more than one element, because the callback function is aware of the target of the click / enter keypress.
Usage:
$.clickOrEnter(yourElement,yourFunction);
$.clickOrEnter('a',popup);
This essentially replaces the style of
<a href="javascript:function();">Foo</a>
<a href="foo.html" onclick="function();" onkeypress="function();">Bar</a>
blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu源
前言: 这篇依旧长,请耐心看下去。 一、事件委托 DOM有个事件流特性,所以触发DOM节点的时候,会经历3个阶段: (1)阶段一:Capturing 事件捕获(从祖到目标) 在事件自上(document->html->body->xxx)而下到达目标节点的过程中,浏览器会检测 针对该事件的 监听器(用来捕获事件),并运行捕获事件的监听器。 (2)阶段二:Target 目标 浏览器找到监听器后,就运
转载 http://www.cnblogs.com/lightsong/p/4034109.html?utm_source=tuicool&utm_medium=referral 原生JS通过什么方法绑定click事件? 原生js有一下三种方法为DOM对象绑定click事件, 第一种,在html中添加 onclick属性,在此属性中添加要绑定的事件函数,如下, 这种方法为html处理事件的