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="lib/jquery-1.6.4.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&amp;tab=photo&amp;view=photo_detail&amp;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&amp;tab=photo&amp;view=photo_detail&amp;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>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值