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);
});
精彩评论