【发布时间】:2012-06-15 12:37:05
【问题描述】:
我有这个:
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;
});
但总是取第一个链接的 rel 值,在本例中为“1”。
为什么? :(
非常感谢! ;-)
【问题讨论】:
-
RTFD。 api.jquery.com/attr "
.attr()方法仅获取匹配集中的 first 元素的属性值。"