开发者

How to find the rel attribute jQuery

I have a bunch of elements that contain the rel attribute.

I'm trying to use this to loop through the elements to get the v开发者_如何学运维alue of each.

$('area').find('rel').each(function(index){
    alert(index);
});

However it doesn't seem to work.


The argument to find is supposed to be a selector. To actually pull out the element values, you want something like:

$('[rel]').each(function() {
    alert($(this).attr('rel'));
});


$('[rel]') would find all nodes with the rel attribute in document.

$('div').find('[rel]') would find all nodes with the rel attribute in under any div.


Nevermind figured it out.

$('area[rel]').each(function(index){
    alert(index);
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜