jQuery之第4章 jQuery中的事件和動畫

來源:互聯網
上載者:User

標籤:io   使用   ar   java   on   cti   ad   ef   javascript   

一、jQuery中的事件:

  1、載入DOM:

    jQuery:$(document).ready();

    JavaScript:window.onload();

    $(window).load(function(){

    })  等價於

    window.onload = function(){}

  簡寫方式:

  (1)$(document).ready(functon(){})

  (2)$().ready(functon(){})

  (3)$(function(){})

  2、事件綁定:

    bind();

  3、合成事件:

  (1)hover() :用於類比游標懸停事件。

  (2)toggle() :用於類比滑鼠連續單擊事件。另一作用,切換元素的可見狀態。

  4、事件冒泡:

    event.stopPropagation();  //停止事件冒泡

    event.preventDefault();  //阻止預設行為

    改寫為:

    return false;

   事件捕獲:

    jQuery不支援事件捕獲,需要使用JavaScrip原生實現。

  5、事件對象的屬性:

  (1)event.type

  (2)event.stopPropagation();

  (3)event.preventDefault();

  (4)event.target

  (5)event.relatedTarget

  (6)event.pageX、event.pageY

  (7)event.which

  (8)event.metaKEY

  6、移除事件:

  unbind();

  one();

  7、類比操作:

  trigger();

    

jQuery之第4章 jQuery中的事件和動畫

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.