views:

261

answers:

2

Hi, The title sounds confusing.. but im sure this is possible!

I have one button, (id='downloadAll') and many <a href="..." class="link"></a> on my page. What i want to do, for the purpose of finding out how to do this.. is to do something logic like this.

var hrefs = ALL OF THE ELEMENTS WITH CLASS 'link';
foreach(hrefs){
 alert(this.attr('href'));
}

Basically for each of the elements with a class, i want to get the value of each one... in tern. Yes, i do have jquery on the page - am hoping to make use of this!

Thanks!

+7  A: 
$("a.link").each(function() {
  alert($(this).attr("href"));
});
cletus
Ah! haha thanks! i found that literally 2 seconds before you posted ;) thanks!!
tarnfeld
A: 

You should make something like this $.each(hrefs, function(){ alert(this.href); });

Igor