I have a page that contains two links with the same text “Add new item”, but are targeting different URLs.
I created a javascript that uses jQuery library which references the link by its text. The code is:
var anchorElement = $("a:contains('Add new item')");
This is fine when I want to reference the first link. But, how do I reference the second one, being that they have the same text? Thanks.
To loop through use this
You can also grab them by index