I am attempting to get all links on a page where the link name and href are the same and assign a value to the return name to make the reference to that link unique.
So if a page had the following three identicial links:
<a href="link1" class="adobeTrackedCustomLink">About Us</a>
<a href="link1" class="adobeTrackedCustomLink">About Us</a>
<a href="link1" class="adobeTrackedCustomLink">About Us</a>
The expected result if second link clicked the return would be:
aboutus-link1-2
I can get the link name and href returned as below:
var linkname = $(input).text().trim().replace(/\W/g, '').toLowerCase();
var hrefname = $(input).closest('a').attr("href").replace(/\W/g, '').toLowerCase();
return linkname + '-' + hrefname;
But I don't know how I would do the ID on the end, any help would be appreciated.