jQuery 事件处理API

click()事件

focus() 和 blur()事件不支持冒泡,focusin和focusout支持

mouseenter和mouseleave不支持冒泡 mouseover和mouseout支持

hover()方法用来给mouseenter和mouseleave事件注册处理程序

hover(handlerIn,handleOut) Bind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements.

hover(handlerInOut) : Bind a single handler to the matched elements, to be executed when the mouse pointer enters or leaves the elements.

 jQuery事件的基本概念

jQuery()事件对象模拟标准的event对象

jQuery()事件处理函数的返回值始终有意义,返回false意味着调用了preventDefault()和stopPropagation(),返回的非undefined值会存储在事件对象的result中,便于后面的连续处理事件访问

jQuery事件对象的常用属性:

pageX,pageY鼠标的文档坐标

target发生事件的文档元素 currentTarget当前正在执行的事件处理程序所注册的元素 relatedTarget在鼠标悬浮及离开事件时,表示鼠标指针移开的元素

timestamp事件发生的时间

data注册事件处理程序时指定的额外数据

handler当前被调用的事件处理程序的函数引用

result函数的返回值

事件方法

jQuery()的事件触发机制是同步的,不涉及事件队列

.bind()已弃用改为.on() : Attach an event handler function for one or more events to the selected elements.

.unbind()被替换为.off() :Remove an event handler.

trigger()触发事件 :Execute all handlers and behaviors attached to the matched elements for the given event type.

.triggleHandler()

  • The .triggerHandler( "event" ) method will not call .event() on the element it is triggered on. This means .triggerHandler( "submit" ) on a form will not call .submit() on the form.
  • While .trigger() will operate on all elements matched by the jQuery object, .triggerHandler() only affects the first matched element.
  • Events triggered with .triggerHandler() do not bubble up the DOM hierarchy; if they are not handled by the target element directly, they do nothing.
  • Instead of returning the jQuery object (to allow chaining), .triggerHandler() returns whatever value was returned by the last handler it caused to be executed. If no handlers are triggered, it returns undefined

原文地址:https://www.cnblogs.com/goOtter/p/9534096.html

时间: 2024-08-28 06:30:30

jQuery 事件处理API的相关文章

Unit02: jQuery事件处理 、 jQuery动画

Unit02: jQuery事件处理 . jQuery动画 jQuery实现购物车案例 <!DOCTYPE html> <html> <head> <title>购物车</title> <meta charset="utf-8" /> <style type="text/css"> h1 { text-align:center; } table { margin:0 auto; wi

jQuery EasyUI API 中文文档

http://www.cnblogs.com/Philoo/tag/jQuery/ 共2页: 1 2 下一页 jQuery EasyUI API 中文文档 - 树表格(TreeGrid) 风流涕淌 2011-11-19 18:51 阅读:25025 评论:3 jQuery EasyUI API 中文文档 - 树(Tree) 风流涕淌 2011-11-18 20:13 阅读:31937 评论:2 jQuery EasyUI 1.2.4 API 中文文档(完整)目录 风流涕淌 2011-11-17

jQuery EasyUI API 中文帮助文档和扩展实例

下载地址:jQuery EasyUI API 中文帮助文档 1.validatebox验证和提示框扩展: //弹框 $.extend({ show_alert: function (strTitle, strMsg) { $.messager.alert(strTitle, strMsg); } }); //扩展validatebox,添加验证 $.extend($.fn.validatebox.defaults.rules, { eqPwd: { validator: function (va

jquery 常用api

*一)jQuery常用方法API实战 (1)DOM简述与分类 A)DOM是一种标准,它独立于平台,语言,浏览器. B)如果项目中,你完全按照DOM标准写代码,你就能在各大主流的浏览器中操作标准控件. C)参见<<>> (2)jquery操作DOM的常用API实战 父.append(子) 父.prepend(子) ------------------------------ A.after(B):B在A之后 A.before(B):B在A之前 --------------------

jQuery事件处理(一)

1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>jQuery 事件处理(一)</title> 6 <script type="text/javascript" src="jquery-1.7.2.min.js"></script> 7 <script ty

jQuery EasyUI API 中文文档 - ValidateBox验证框

jQuery EasyUI API 中文文档 - ValidateBox验证框,使用jQuery EasyUI的朋友可以参考下. 用 $.fn.validatebox.defaults 重写了 defaults. 用法 代码如下: <input id="vv" required="true" validType="email"> 代码如下: $('#vv').validatebox({ required:true }); 验证规则 验

JavaScript强化教程——jQuery UI API 类别

主要介绍:JavaScript强化教程-- jQuery UI API 类别 jQuery UI 在jQuery 内置的特效上添加了一些功能.jQuery UI 支持颜色动画和 Class 转换,同时也提供了一些额外的 Easings.另外,提供了一套完整的定制特效,供显示和隐藏元素时或者只是添加一些视觉显示时使用. API     描述      也属于类别 .addClass()     当动画样式改变时,为匹配的元素集合内的每个元素添加指定的 Class. 特效核心(Effects Cor

jQuery EasyUI API - Grid - DataGrid [原创汉化官方API]

jQuery EasyUI API - Grid - DataGrid [原创汉化官方API] 2014-04-02   DataGrid 继承自 $.fn.panel.defaults,覆盖默认值 $.fn.datagrid.defaults. DataGrid控件显示数据以表格的形式提供了丰富的选择,支持排序,组和编辑数据. DataGrid控件被设计来减少开发时间和要求开发商没有特定的知识.它是轻量级的和功能丰富的.合并单元格,多列标题,冻结列和页脚是仅有的几个特点. [依赖于] pane

jquery 事件处理handler函数的参数

jquery 事件处理handler函数的参数  在如下的函数中,我们在处理jquery里经常使用: $( "#foo" ).bind( "click", function() { alert( $( this ).text() ); }); click的handler处理函数一般为function(){},不传参数.那么,这个函数可以接收参数么,内置了什么对象,有什么返回值,怎么获得事件绑定的对象? 1.第一个参数event对象,在function函数里,实际上第