On a page I have 10 elements with the same class name:
<span class="simpleclass">text</span>
What I’m trying to do is – go to the next element with class “simpleclass” when the page is scrolled. That means that for the first time when I scroll the page I need to get a reference to the second span with class “simpleclass” on the page, etc. Could anybody help me to figure out how this can be achieved?
Thanks.
Create a global variable for tracking the current
span:Then, whenever the page is scrolled, you can get the next
spanand increment thecurrentSpanvariable: