-2
我有這樣的:相對ATTR與jQuery總是拿第一價值
HTML:
<div id="selectedsongs">
<a href="#" rel="1">song1></a>
<a href="#" rel="2">song2></a>
<a href="#" rel="3">song3></a>
</div>
然後:
selectedBtn = $('#selectedsong');
selectedBtn.click(function()
{
self.selectedsong($('a', this).attr('rel'));
return false;
});
但始終把第一連桿的相對價值,這種情況下,值「1」。
爲什麼? :(
非常感謝你;-)
RTFD。 http://api.jquery.com/attr/「.attr()'方法僅爲匹配集中的_first_元素獲取屬性值。」 –