I've got a system generated table that houses links in each of it's row elements. Each of these links has a unique 4 digit value at the end of the link.
The goal is to iterate through each of these table elements, grab the link it holds and then slice that link down to just the final 4 characters.
I've got this running right now:
HTML
<td class="lc_Cell">
<p>
<a href="thelink">Link #1</a>
</p>
</td>
<td class="lc_Cell">
<p>
<a href="thelink">Link #2</a>
</p>
</td>
<td class="lc_Cell">
<p>
<a href="thelink">Link #3</a>
</p>
</td>
<td class="lc_Cell">
<p>
<a href="thelink">Link #4</a>
</p>
</td>
Jquery
var TRLink = $(".lc_Cell > p > a").attr("href"); //The original URL the program spits out
var TR_ID = TRLink.slice(-4); // Storing just the 4 digits I need
var NewLink = $(".lc_Cell > p > a").attr("href","mynewlinktosendsomeoneto"+ TR_ID);
// my new link that utilizes the 4 characters from the original
This kind of works... the initial variable stores the link of the first instance it finds (in my actual code there are 3 others). When I create the NewLink variable it then overwrites ALL occurrences.
In a perfect world I'd iterate through and store the original links, do my slice and then iterate through and re-build a new link for each.
I came across the "each.()" command in jQuery but didn't have much luck getting a solution to work on my own.
Any help is greatly appreciated!