I’m working with a page that has several links that contain the same href text, and I need to select the second anchor element on the page that contains said href text. Here’s a simplified version of the link structure of the page:
<a href="same/link/to/stuff/">same link</a>
<a href="same/link/to/stuff/">same link</a>
How do I fashion my selector so that it only selects the second anchor in the above example?
Currently I’m trying:
$('a[href=same/link/to/stuff/] :eq(1)')
but it is not working.
Thanks!!
As Patrick Karcher noted, you’re missing a slash.
Also, you shouldn’t have a space before
:eq(1).Spaces in selectors imply that the item after the space is a descendant of the item before the space.
The way you had it, you were attempting to select the second descendant element of
a[href=same/link/to/stuff/].