Squirrl Squirrl - 1 year ago 60
jQuery Question

How to get an href within a HTML element?

I'm looping through a list of objects like this:

for (var i=0;i<rows.length;i++) {

and it's outputting html like this:

<td style="padding-left: 1em">
<a href="/assets/images/royce/royce-trumbull-09.jpg">royce-trumbull-09.jpg</a>

And I'm simply trying to get the href attribute from each
like the one above. I tried
among other things. I just want to return

Answer Source

Looks like you need


right? Since your output for rows[i].children[2] is the td element, not the a inside it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download