-2

How will I address the elements that are nearby?

I have this html

<button class="prev" onclick="prevtrack">Prev</button>
<button class="next" onclick="nexttrack">Next</button>
    <ul>
        <li>Need this item (Prev)</li>
        <li class="active"></li>
        <li>Need this item (Next)</li>
    </ul>

But there may be such an option

<ul>
    <li></li>
    <li>Need this item</li>
    <li class="active"></li>
</ul>

nth: it does not suit me (because I need a number of Nearby elements) enter image description here

  • @Aluan Haddad i shared image, i clicked on button NEXT and this click go to
  • – Сергей Гончарь-Лысенко Apr 10 '18 at 23:21
  • I refuse to look at an image. Post the code as text – Aluan Haddad Apr 10 '18 at 23:28
  • @Aluan Haddad
    • Need this item
    • Need this item
    – Сергей Гончарь-Лысенко Apr 10 '18 at 23:43
  • @СергейГончарь-Лысенко you keep repeating yourself but you're not making yourself clearer – Aluan Haddad Apr 10 '18 at 23:44
  • @Aluan Haddad , i edit Html in question – Сергей Гончарь-Лысенко Apr 11 '18 at 01:08
  • I'm voting to close this as you haven't provided an MVCE – Aluan Haddad Apr 11 '18 at 03:17
  • @Aluan Haddad I found a solution, See my answer! – Сергей Гончарь-Лысенко Apr 11 '18 at 23:24
  • @СергейГончарь-Лысенко it's of even lower quality than the question – Aluan Haddad Apr 12 '18 at 04:09