资讯专栏INFORMATION COLUMN

jQuery Event Menthods

khlbat / 2424人阅读

Here are some common DOM events

1 Mouser Events

click dbclick mouseenter mouseleave

2 Keyborars Events

keypress keydown keyup

3 Form Events

submit change focus blus

4 Docment/Wiindow Events

laod resize scroll unload

click()
the function is executed when the user clicks on the html element.
eg:

 $("p").click(function(){
    $(this).hide();
})

dblclick()

the dblclick() method attaches an event handlerfunction to an html element. the function is executed when the user double-clicks on the html element

eg:

 $("p").dblclick(function(){
    $(this).hide();
})

mouseenter()
the function is executed when the mouse pointer the html element
eg:

 $("p").mouseenter(function(){
    alert("you entered p");
})

mouseleave()

the function is executed when the mouse pointer leaves the html element

eg:

    $("#p").mouseleave(function(){
    alert("bye! you now leave p");
    })

mousedown()
the function is executed , when the left,middle or right button is pressed down, while the mouse is over the html element
eg:

 $("p").mousedown(function(){
    alert("mouse down over p");
})

mouseup()

the function is excuted, when the left.miffffdle or right mouse button is released while the nouse is over the html element
eg:

$("p").mouseup(function(){
alert("mouse up over p");
})

hover()
the hover() method takes two functions and is a combination of the mouseenter() and mouseleave() methods
the first function is executed when the mouse enters enters the html element, and the second function is executed when the mouse leaves the html element

eg:

$("p").hover(function(){
alert("you entered p");
},funtion(){
alert("bye! you now leave p");
})

focus()
the focus() methods attaches an event handler function to an html form the function is executed when the form field gets focus

eg:

$("input").focus(function(){
$(this).css("background-color","#cccccc");
});

blur()
the blur() method attaches an eveent handler function to an html
the function is executed when the form field loses focus

$("input").blur(function(){
$(this).css("background-color","#ffffff");
})

on()
the function attaches one or more event handlers for selected selected
elements
eg:

$("p").on("click",function(){
$(this).hide();
})

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/86896.html

相关文章

  • jQuery源码解析之jQuery.event.dispatch()

    摘要:一起源方法最终是用绑定事件的而方法正是等于二作用触发绑定的事件的处理程序源码源码行即原生触发事件的处理程序修正对象获取事件的处理程序集合,结构如下从数据缓存中获取事件处理集合即目标元素委托目标这段代码压根不会执行,因为全局搜索没找到结构 showImg(https://segmentfault.com/img/remote/1460000019464031); 一、起源jQuery.e...

    GraphQuery 评论0 收藏0
  • jQuery 源码系列(十三)事件处理源码

    摘要:专门为事件建立一个有问题,直接退出如果是一个事件处理对象,且有属性。参考源码分析事件体系结构解密事件核心绑定设计一解密事件核心委托设计二本文在上的源码地址,欢迎来。 欢迎来我的专栏查看系列文章。 通过前面一章对于 addEvent 库的介绍,它的兼容性超级棒,据说对于 IE4、5 都有很好的兼容性,这和 jQuery 的原理是一致的,而在 jQuery 中,有一个对象与其相对应,那就是...

    刘厚水 评论0 收藏0
  • jQuery 源码系列(十四)自定义事件

    摘要:不过也有自己的一套自定义事件方案。可以和事件拿来对比,他们都是用来模拟和执行监听的事件。冒泡事件就是就是由内向外冒泡的过程,这个过程不是很复杂。参考解密事件核心自定义设计三解密事件核心模拟事件四本文在上的源码地址,欢迎来。 欢迎来我的专栏查看系列文章。 以前,我只知道,只有当对浏览器中的元素进行点击的时候,才会出发 click 事件,其它的事件也一样,需要人为的鼠标操作。 showIm...

    elliott_hu 评论0 收藏0
  • jQuery源码学习之event

    摘要:回调队列中的元素是对象,代表一个事件回调,拥有多个属性,如等等,其中是回调函数,在触发时通过传递,具体的在后面讲。类型是时键表示事件名,规则同上,键值表示事件触发时的回调函数。 jQuery源码学习之event jQuery的事件机制为异步回调,事件监听的属性、参数和回调的等保存在Data实例中,在元素上保存该对象的引用。有方法handle,内部执行dispatch;有属性events...

    XboxYan 评论0 收藏0

发表评论

0条评论

khlbat

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<