mouse event

Mouse events are fired when the user moves the mouse cursor or clicks with any mouse button.
1. Click event:
  $('p').click(function(){}) is triggered when the left mouse button is clicked;
Example:

$('p').click(function(){
        alert('click function is running ! ');
       });
2. dbclick event:
  $('p').dbclick(function(){});
Example:

$("button").dblclick(function(){
$("p").slideToggle();
});
3. mousedown event: trigger
  $('p').mousedown(function(){});
example

$("button").mousedown( function(){
$("p").slideToggle();
});
4. mouseup event: trigger
  $('p').mouseup(function(){});
example:

$("button ").

}); 5. mouseover event: the   mouseout event
is triggered when the mouse moves from one element to another :   $('p').mouseover(function(){});   $('p').mouseout (function(){}); Example: $("p").mouseover(function(){ $("p").css("background-color","yellow"); }); $("p ").mouseout(function(){ $("p").css("background-color","#E9E9E4"); }); 6. mouseenter event: the      mouseleave event is triggered when the mouse moves into the element: when the mouse moves out of the element Trigger   $('p').mouseenter(function(){});   $('p').mouseleave(function(){}); Example $("p").mouseenter(function(){ $(" p").css("background-color","yellow" ); }); $("p").mouseleave(function(){





















$("p").css("background-color","#E9E9E4");
});
7、hover事件
  $('p').hover(
    function(){},
    function(){}
  );
示例

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

);
8、toggle事件:鼠标点击切换事件
  $('p').toggle(
    function(){},
    function(){}
  );
示例

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326189422&siteId=291194637