Jquery: Extracting the hrefs from multiple links on a page.
- by Pete B
Hi,
I discovered that .attr() only applies to the first matched element on the page! So, I've been trying to get the hrefs from all the matched elements on a page, but to no avail.
Here's what I tentatively wrote:
var thelinks = $("td a").each(function(){
$(this).attr("href");
document.write(thelinks);
});
I used document.write just to see what was going on, and I got a long list of "undefinedundefinedundefined"
What I'm trying to do is extract the hrefs from each td a and then use ajax to visit those pages and do other stuff. I can get it work fine when it's dealing with just one link, but this multiple elements thing I can't figure out.
Any help rendered is appreciated, I'm a novice to the world of Javascript and Jquery.