2011-11-03 22 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 –