Reputation: 36215
I have a complex jquery expression which I have stored in the variable "that":
that = $('table[class=a]').find('a[href^="xx"]').closest('td')[0]
<td>
<a href="xx....">
</td>
I'm not sure how to open the contained link using "that" as the starting point. I tried
$(that>'a').each(function(){
window.location.href = $(this).attr('href');
});
this yields an empty set in firebug. How can I fix this?
Upvotes: 0
Views: 55
Reputation: 173522
Instead of trying to find the first enclosing <td>
, you can simply shorten the expression to get only the anchors:
$('table.a a[href^="xx"]').each(function() {
location.href = this.href;
return false;
});
This will take the first anchor, and if it exists, change the location.
Upvotes: 2