I am trying to understand how a “far” remote element in the DOM relates to a specific other element.
<li>item1</li>
<li>item2</li>
<li class="active">item3</li>
<li>item4</li>
<li>item5</li>
<li>item6</li>
<li>item7</li>
Therefore, when a user clicks on an item, he must return the distance to the active element: So item1: return -2, item4: return 1, item6: return 3etc.
source
share