jQuery事件之滑鼠事件

來源:互聯網
上載者:User

標籤:style   blog   http   color   使用   os   io   ar   

滑鼠事件是在使用者移動滑鼠游標或者使用任意滑鼠鍵點擊時觸發的。
   (1):click事件:click事件於使用者在元素敲擊滑鼠左鍵,並在相同元素上鬆開左鍵時觸發。
        $(‘p‘).click(function(){
                alert(‘click function is running !‘);
              });
    (2):dbclick事件:dbclick事件在使用者完成迅速連續的兩次點擊之後觸發,雙擊的速度取決於作業系統的設定。一般雙擊事件在頁面中不經常使用。
        $(‘p‘).dbclick(function(){
                alert(‘dbclick function is running !‘);
              });
    (3):mousedown事件:mousedown事件在使用者敲擊滑鼠鍵時觸發,跟keydown事件不一樣,該事件僅在按下滑鼠時觸發。
        $(‘p‘).mousedown(function(){
                alert(‘mousedown function is running !‘);
              });
    (4):mouseup事件:mouseup事件在使用者鬆開滑鼠時觸發,如果在與按下滑鼠的元素相同元素上鬆開,那麼click事件也會觸發。
        $(‘p‘).mouseup(function(){
                alert(‘mouseup function is running !‘);
              }).click(function(){
                 alert(‘click function is running too !‘);
                 });
    (5):mouseover事件:mouseover事件於使用者把滑鼠從一個元素移動到另外一個元素上時觸發,如果需要知道來自那個元素可以使用,relatedTagrget屬性。
    (6):mouseout事件:mouseout事件於使用者把滑鼠移出一個元素時觸發,這包括從父元素移動到子項目上,或者使用鍵盤跳到元素上。
   (5)和(6)這兩個事件一般不常用,很難實現與使用者的互動,也就是說不易捕獲使用者事件。
    (7):mouseenter事件:mouseenter事件是在使用者游標進入元素上時觸發。
         $(‘p‘).mouseenter(function(){
                alert(‘mouseenter function is running !‘);
              });
    (8):mouseleaver事件:mouseleaver事件是在使用者的游標離開元素時觸發。
           $(‘p‘).mouseleaver(function(){
                alert(‘mouseleaver function is running !‘);
             });
     (7)和(8)這兩個事件一般連起來使用,在jQuery中可以使用hover這個函數來代替這兩個函數。
       $(‘p‘).hover(function(){
                       alert(‘mouseenter function is running !‘);
                      },function(){
                              alert(‘mouseleaver function is running !‘);
                         });

 

 

來自: http://hi.baidu.com/yejiejay/blog/item/19374ffb69a064076d22eba3.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.