2011-11-03 79 views
1
<a href="random-link"> 
<img alt="My Photo" class="profile-img" height="80" src="img" width="80"> 
</a> 

你怎么应用这个jQuery .attr('target','_blank');<a href="link">所以添加属性来包装元素使用jQuery

<a href="random-link" target="_blank"> 
<img alt="My Photo" class="profile-img" height="80" src="img" width="80"> 
</a> 

回答

3

万一@Yusaf使用link为模糊链接的结果将是,你可以试试这个:

$('.profile-img').parent('a').attr('target', '_blank'); 
+0

perfect thankyou –