0

I have this code which generates bunch of tabs

<li ng-repeat="nav in navs">
    <a href="" id="{{$index}}" ng-class="{'selected-nav': nav.state === selectedTab}" tabindex="{{nav.state === selectedTab ? 0 : -1}}">
       <span>Some icon</span>
       <span>Some text</span>
    </a>
</li>

Now, i want to navigate through these tabs using arrow keys, I mean i want the focus to move to next element if I use right arrow key and want to move focus to previous element using left arrow key.

I tried this, but it's not gonna work because the elements are generated dynamically, any help??

if(event.which === 39 || event.which === 40) {
document.getElementById('1').focus();
}

Thanks in advance!

Apple Pie
  • 83
  • 3
  • 12

0 Answers0