在這裏,在這個網站,我需要得到的圖像名稱arrow_down使用jQuery和獲取圖像名稱後,在我的代碼將其設置爲可變x.Here我在使用該名稱,如果其他條件如何使用jquery查找圖像名稱?
<a style="color: #FFFFFF; text-decoration: none;" id="imageDivLink" href="#">
<img name="arrow" class="img-swap" src="Images/arrow_down.jpg" width="13" height="13" border="0" alt="" /></a>
和
$('#imageDivLink').click(function() {
var x = $("img[src$='arrow_down.jpg'][name='arrow']");
if (x == arrow_down) {
$('#MainContent_IFTrendAnalysis').animate({ height: '+=120' }, 500);
}
else {
$('#MainContent_IFTrendAnalysis').animate({ height: '-=120' }, 500);
}
});
有什麼建議嗎?
你想要'src'屬性中的'name'屬性或圖像名稱嗎? – 2012-04-03 13:01:27
$('#imageDivLink')。children('img')。attr('name');應該管用 – 2012-04-03 13:00:51