jQuery Event Menthods

hlcc

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();
})
阅读 1k

贺兰丛丛
关于php、liunx、nginx、js 方面的技术文章。

放养程序员

106 声望
9 粉丝
0 条评论

放养程序员

106 声望
9 粉丝
文章目录
宣传栏