2014-04-08 80 views
0

這裏下一個圖像標籤是我的代碼查找基於<標籤

<a target="_blank" href="http://www.home.test.com/test/redirector.jspx?  
action=ref&cname=EDITORIAL&ckey=2259303&cc=US&lc=eng&cmpid=MA41335AM"  
style=cursor:hand ;color: #ffffff ;text-decoration:none"> 

<img height="250" src="http://newsletters.tm.agilent.com/epsg/13MR/MCD-CID/11_CC_020783- 
N9322C/N9322C_Application.jpg" alt="Basic spectrum analyzer" style="padding 0 0 0  
0;margin:0 0 0 0;"border="0"></a> 

現在的問題是我想要找的IMG alt屬性基於href標記文本。 它是動態生成的,因此它可以是任何東西,沒有任何發現的href最接近img標籤或HREF未來img標籤的方法..

回答

0

直子選擇將是這裏最好的

$('a > img').attr('alt'); 
+0

遺憾沒工作 – win

+0

我我在每個函數中迭代它,所以在整個html中我必須找到href和它最接近的img alt文本$(filteredText).find('a [href]')。each(function(){var tt = $(this ).attr('href'); href + = $(this).attr('href')+'〜'+ $(this).text()+「|」;})現在我必須找到最接近img替代文字與此功能 – win