jQuery的層級查找方式分析
更新時間:2016年06月16日 12:00:01 作者:hbiao68
這篇文章主要介紹了jQuery的層級查找方式,結合實例形式分析了jQuery常用的三種層級查找的使用技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實例分析了jQuery的層級查找方式。分享給大家供大家參考,具體如下:
下面使用jquery的層級查找方式
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <script src="jquery-1.6.2.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready( function(){ /*第一種方式層級查找,查找的是a標簽對象——選擇器*/ $('.thumb-hover a:has(img)').each(function(){ alert($(this).attr("pid")); }); /*第三種層級查找,使用方法進行篩選——篩選器*/ $('.thumb-hover a').has("img").each(function(){ alert($(this).attr("pid")); }); /*第二種方式層級查找,查找的是img標簽對象——基本層級選擇器*/ $('.thumb-hover a img').each(function(){ alert($(this).attr("alt")); }); } ); </script> <title>無標題文檔</title> </head> <DIV class=thumb sizcache="17" sizset="84"> <SPAN class=thumb-hover sizcache="17" sizset="84"> <A class=lightbox-enabled href="/user/showuser.php?uid=u1373373094&tab=photo&view=photo_detail&pid=72464692#detail" target=_blank pid="72464692" oid="27" src="http://pic03.babytreeimg-dev.com/foto3/thumbs/2012/0106/43/8/51dc02a6279c0ef6c728e5_mb.jpg" jQuery1640004568396895048288="1"> <IMG alt=DSC_0723.JPG src="http://pic05.babytreeimg-dev.com/foto3/thumbs/2012/0106/43/8/51dc02a6279c0ef6c728e5_sm.jpg"> </A> <SPAN style="DISPLAY: none" id=72464692 class=mouse-wrap> <IMG class=unselect src="http://pic.babytree.com/img/mybabytree/photo/pix.png"> </SPAN> </SPAN> </DIV> <DIV class=thumb> <SPAN class=thumb-hover sizcache="0" sizset="2"> <A class=lightbox-enabled href="/user/showuser.php?uid=u3073373044&tab=photo&view=photo_detail&pid=72464732#detail" target=_blank pid="72464732" oid="5" src="http://pic02.babytreeimg-dev.com/foto3/thumbs/2012/0216/48/9/b72ff3742c8c172650a0d1_nb.jpg" jQuery16405726906849340585="1"><IMG alt=Koala.jpg src="http://pic01.babytreeimg-dev.com/foto3/thumbs/2012/0216/48/9/b72ff3742c8c172650a0d1_sm.jpg"> </A> <SPAN style="DISPLAY: none" id=72464732 class=mouse-wrap> <IMG class=unselect alt=DSC_0724.JPG src="http://pic.babytree.com/img/mybabytree/photo/pix.png"> </SPAN> </SPAN> </DIV> <body> </body> </html>
更多關于jQuery相關內容感興趣的讀者可查看本站專題:《jQuery常用插件及用法總結》、《jquery中Ajax用法總結》、《jQuery表格(table)操作技巧匯總》、《jQuery拖拽特效與技巧總結》、《jQuery擴展技巧總結》、《jQuery常見經典特效匯總》、《jQuery動畫與特效用法總結》及《jquery選擇器用法總結》
希望本文所述對大家jQuery程序設計有所幫助。
相關文章
jquery實現(textarea)placeholder自動換行
本文主要對jquery如何實現(textarea) placeholder自動換行的方法、思路進行介紹,下面就跟小編一起來看下吧2016-12-12easyui datagrid 表格中操作欄 按鈕圖標不顯示的解決方法
下面小編就為大家?guī)硪黄猠asyui datagrid 表格中操作欄 按鈕圖標不顯示的解決方法。小編覺得挺不錯的,現在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-07-07