jQuery Event Menthods

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.midddle 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();
})
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值