jquery小知識點

來源:互聯網
上載者:User

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

1、children()和find()的差別children方法獲得的僅僅是元素一下級的子項目,find方法獲得所有下級元素

 

2、防止冒泡:

  1、event.stopPropagation();

  2、e.target 是目標對象,e.event是目標所發生的事件。

    if($(e.target).is("li.link")){}

 

3、mouseover()、mouseout()和mouseenter()、mouseleave()的差別,另外加上hover

  jquery源碼中有這麼一段:

hover: function( fnOver, fnOut ) {    return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );  }

 

  hover()就是mouseenter()和mouseleave()的結合。

  而mouseover().mouseout()這個會出很多問題,因為這個或涉及到冒泡,遇到了一次,簡直把我弄瘋了。其重要原因是mouseover()和mouseenter()的區別,另外兩個一樣。

  在w3school上面可以很清楚的知道差別。http://www.w3school.com.cn/tiy/t.asp?f=jquery_event_mouseenter_mouseover

  mouseover()對一個div綁定後,不是把div看做一個整體,當div裡面有其他元素時,它會將裡面的每一個標籤對看做一個個體,並會對這裡面的所有個體都綁定了這個事件;而mouseenter()是把div看做一個整塊,只對這個整塊兒綁定此事件。

  所以以後要謹慎使用mouseover()了。

  

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.