2014-03-07 103 views

回答

2

使用.lengthfind()

if($(this).find('img').length) 
alert("yes"); 
1

您可以测试

if ($('img', this).length) alert('yes'); 

更具体地说,这种警报如果这里面元素的集合,其标签是img具有非零大小。

2

你可以使用:

if($(this).find('img').length) alert('yes'); 
1

尝试

<div id="container">asdasdas 
<img/> 
</div> 


$("#container").click(function(){ 
if($(this).has("img").length) 
{ 
alert("yes"); 
} 
}); 

DEMO

相关问题