I’ve got a page which is split into separate sections. Within each section I need to number a link relevant to that section.
- Section 1 (with 1 link) has its link numbered as 1
- Section 2 (with 3 links) has it’s links numbered 1, 2 & 3 according to the order they are in
My approach is I’m using .data() to assign information to each section and also to each link within those sections so I can then extract this later on. At the moment though, rather than numbering each link in relation to the link’s parent section, the JS is numbering according to all of the links within the page.
I believe the problem is the .each I’ve specified for the links within the section, as it’s relational to the page, rather than relational to each section. Essentially what I want to do is reset the count for each section so that the sections are treated separately.
Here’s what I have so far (see console log and click each of the buttons):
Thanks in advance!