老熟女激烈的高潮_日韩一级黄色录像_亚洲1区2区3区视频_精品少妇一区二区三区在线播放_国产欧美日产久久_午夜福利精品导航凹凸

重慶分公司,新征程啟航

為企業提供網站建設、域名注冊、服務器等服務

jQuery:掌握選擇器

選擇器至少可以追溯到“CSS選擇器”。jQuery的源代碼中內嵌了一個叫Sizzle的對象,其實就是選擇器了。在jQuery官網上顯示Sizzle屬于“Other jQuery Foundation Projects”,Sizzle能夠獨立為一個單獨的項目,由此不難體會到選擇器的重要性。看看下面三個頁面,相比之下,jQuery選擇器官方文檔看起來是最“亂”的。

專注于為中小企業提供網站設計制作、成都網站制作服務,電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業西烏珠穆沁免費做網站提供優質的服務。我們立足成都,凝聚了一批互聯網行業人才,有力地推動了成百上千家企業的穩健成長,幫助中小企業通過網站建設實現規模擴充和轉變。

  1. http://www.w3.org/TR/css3-selectors
  2. CSS選擇器W3C標準文檔
  3.  
  4. https://github.com/jquery/sizzle/wiki/Sizzle-Documentation
  5. Sizzle文檔
  6.  
  7. http://api.jquery.com/category/selectors/
  8. jQuery選擇器官方文檔

jquery1.9.0源代碼有這樣一行:

  1. jQuery.find = Sizzle; 
 
導入jquery.js和sizzle.js,可以看到jQuery.find和Sizzle確實是一回事。
 
  1. iJs.showObjectNames("window.jQuery.find");  
  2. iJs.showObjectNames("window.Sizzle"); 

    [Object] window.jQuery.find
        |--[function] attr
        |--[function] compile
        |--[function] contains
        |--[function] error
        |--[function] getText
        |--[function] isXML
        |--[function] matches
        |--[function] matchesSelector
        |--[function] setDocument
        |--[function] uniqueSort
        |--[object] selectors
    
    [Object] window.Sizzle
        |--[function] attr
        |--[function] compile
        |--[function] contains
        |--[function] error
        |--[function] getText
        |--[function] isXML
        |--[function] matches
        |--[function] matchesSelector
        |--[function] setDocument
        |--[function] uniqueSort
        |--[object] selectors
 
既然Sizzle自稱"supports virtually all CSS 3 Selectors",那么不妨就參考下面W3C描述吧,再難找到更好的文檔片斷了(點擊鏈接可查看語法細節),不是么?
 (備注:這個Table貼過來總是出現顯示問題,于是對html代碼進行了編輯,其中一個替換是(]*">)[^<]*()替換為$1更多$2)
語法 含義 鏈接 版本
* any element 更多 2
E an element of type E 更多 1
E[foo] an E element with a "foo" attribute 更多 2
E[foo="bar"] an E element whose "foo" attribute value is exactly equal to "bar" 更多 2
E[foo~="bar"] an E element whose "foo" attribute value is a list of whitespace-separated values, one of which is exactly equal to "bar" 更多 2
E[foo^="bar"] an E element whose "foo" attribute value begins exactly with the string "bar" 更多 3
E[foo$="bar"] an E element whose "foo" attribute value ends exactly with the string "bar" 更多 3
E[foo*="bar"] an E element whose "foo" attribute value contains the substring "bar" 更多 3
E[foo|="en"] an E element whose "foo" attribute has a hyphen-separated list of values beginning (from the left) with "en" 更多 2
E:root an E element, root of the document 更多 3
E:nth-child(n) an E element, the n-th child of its parent 更多 3
E:nth-last-child(n) an E element, the n-th child of its parent, counting from the last one 更多 3
E:nth-of-type(n) an E element, the n-th sibling of its type 更多 3
E:nth-last-of-type(n) an E element, the n-th sibling of its type, counting from the last one 更多 3
E:first-child an E element, first child of its parent 更多 2
E:last-child an E element, last child of its parent 更多 3
E:first-of-type an E element, first sibling of its type 更多 3
E:last-of-type an E element, last sibling of its type 更多 3
E:only-child an E element, only child of its parent 更多 3
E:only-of-type an E element, only sibling of its type 更多 3
E:empty an E element that has no children (including text nodes) 更多 3
E:link
E:visited
an E element being the source anchor of a hyperlink of which the target is not yet visited (:link) or already visited (:visited) 更多 1
E:active
E:hover
E:focus
an E element during certain user actions 更多 1 and 2
E:target an E element being the target of the referring URI 更多 3
E:lang(fr) an element of type E in language "fr" (the document language specifies how language is determined) 更多 2
E:enabled
E:disabled
a user interface element E which is enabled or disabled 更多 3
E:checked a user interface element E which is checked (for instance a radio-button or checkbox) 更多 3
E::first-line the first formatted line of an E element 更多 1
E::first-letter the first formatted letter of an E element 更多 1
E::before generated content before an E element 更多 2
E::after generated content after an E element 更多 2
E.warning an E element whose class is "warning" (the document language specifies how class is determined). 更多 1
E#myid an E element with ID equal to "myid". 更多 1
E:not(s) an E element that does not match simple selector s 更多 3
E F an F element descendant of an E element 更多 1
E > F an F element child of an E element 更多 2
E + F an F element immediately preceded by an E element 更多 2
E ~ F an F element preceded by an E element 更多 3
 
需注意,jQuery()和jQuery.find()返回的對象類型是不一樣的,前者是jQuery.fn,后者是Sizzle。例如,jQuery('html body div#dbg');和jQuery.find('html body div#dbg');都是“選擇”了id為dbg的div,但是前者表示為jQuery.fn對象,后者表示為Sizzle對象。

選擇器的語法是有標準的,逐一嘗試每一種寫法沒有必要,今天學會了也許明天就忘記,不如有文檔在手,用到時再翻閱。需要想一想的是選擇器的價值所在,從根本上來講,選擇器就是幫助我們避免了遍歷DOM(或者也包括XML?)的麻煩。一個兩個的遍歷代碼其實也不難寫,但是網頁上的互動多了就麻煩了,下面是一個隔行選取的代碼片斷,不難體會其中運用選擇器的奧妙所在:

  1.  
  2.     ...測試1... 
  3.     ...測試2... 
  4.     ...測試3... 
  5.     ...測試4... 
 
  •  
  •    
  •     var $myObj = jQuery('div b:nth-child(even)');//選擇器  
  •     $myObj.each(  
  •         function(i){  
  •             var tTemp = jQuery(this).text();  
  •             iJs.put(tTemp);//輸出選擇結果  
  •         });  
  •  
  • 調試信息:
        ...測試2...
        ...測試4...

    當前文章:jQuery:掌握選擇器
    當前路徑:http://www.xueling.net.cn/article/piceio.html

    其他資訊

    在線咨詢
    服務熱線
    服務熱線:028-86922220
    TOP
    主站蜘蛛池模板: 国产精品毛片久久久久久 | 91国内精品视频 | 亚洲另类在线视频 | 国产精品人成A片一区二区 欧美人妖另类hd1080p | 亚洲色偷偷综合亚洲AV伊人蜜桃 | 在线观看亚洲十八禁网站 | 2021亚洲国产精品无码 | 日本aⅴ网站 | 99久久免费精品国产男女性高好 | 亚洲精品AV午夜一区二区三区 | 四虎永久在线高清国产精品 | 性爱在线免费视频 | 国产AV导航大全精品 | 狠狠色综合网 | 欧美一区激情视频在线观看 | 亚洲日韩精品A∨片无码加勒比 | 亚洲国产成在人网站天堂 | 国产成人AV在线影院 | 国产成人A人亚洲精品无码 97人人爽人人爽人人一区二区 | 外国av在线 | 久久精品卫校国产小美女 | 亚洲GV网站男男可播放 | 国产欧美日韩视频免费 | 91精品视频免费观看 | 国产一级毛片国语普通话对白 | 国产毛毛片一区二区三区四区 | 少妇性荡欲视频午夜剧场 | 91黄色在线视频 | 亚洲爆乳成AV人在线视水卜 | 农村少妇无套内谢粗又长 | 久草美女 | 91av在线免费 | 亚洲综合另类欧在线美 | 中国浓毛少妇毛茸茸 | 放荡开放的人妻穿丁字裤凹 | 中文字幕V亚洲日本在线 | 99久久人妻精品免费二区 | 久久99久久98精品免观看软件 | 国产精品日韩欧美一区二区视频 | 国产精品久久高潮无码视频 | 无码人妻一区二区三区免费视频 |