Home > Web Front-end > JS Tutorial > body text

jQuery mouse event summary_jquery

WBOY
Release: 2016-05-16 15:41:35
Original
1037 people have browsed it

Mouse events are triggered when the user moves the mouse cursor or clicks with any mouse button.

1. Click event : Triggered when the left mouse button is clicked

 $('p').click(function(){});

Example:

$('p').click(function(){
        alert('click function is running !');
       });

Copy after login

2. dbclick event : triggered when two clicks are made in quick succession

 $('p').dbclick(function(){});

Example:

$("button").dblclick(function(){
 $("p").slideToggle();
});

Copy after login

3. mousedown event : triggered when the mouse is pressed

 $('p').mousedown(function(){});

Example

$("button").mousedown(function(){
 $("p").slideToggle();
});

Copy after login

4. mouseup event : triggered when the mouse is released

 $('p').mouseup(function(){});

Example:

$("button").mouseup(function(){
 $("p").slideToggle();
});

Copy after login

5. mouseover event : triggered when the mouse moves from one element to another

 mouseout event: triggered when the mouse moves out of an element

 $('p').mouseover(function(){});

$('p').mouseout(function(){});

Example:

$("p").mouseover(function(){
 $("p").css("background-color","yellow");
});
$("p").mouseout(function(){
 $("p").css("background-color","#E9E9E4");
});

Copy after login

6. mouseenter event : triggered when the mouse moves into an element

mouseleave event: triggered when the mouse moves out of an element

 $('p').mouseenter(function(){});

$('p').mouseleave(function(){});

Example

$("p").mouseenter(function(){
 $("p").css("background-color","yellow");
});
$("p").mouseleave(function(){
 $("p").css("background-color","#E9E9E4");
});
Copy after login

7. Hover event

 $('p').hover(
function(){},
function(){}
);

Example

$(".table_list tr").hover( 
function () { 
$(this).addClass("hover"); 
}, 
function () { 
$(this).removeClass("hover"); 
} 

); 
Copy after login

8. toggle event : mouse click switching event

 $('p').toggle(
function(){},
function(){}
);

Example

$("p").toggle(
 function(){
 $("body").css("background-color","green");},
 function(){
 $("body").css("background-color","red");},
 function(){
 $("body").css("background-color","yellow");}
);
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!