Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to navigate to anchor tag with tab key if it doesn't have an href?

Tags:

html

angular

I've got a navbar in our app that has a bunch of buttons that are links to other pages, and then a conditional logoff/logon button. That button is an <a>, but it just has (click) and no href or routerLink. As such, I can't tab to it. I added routerLink="" which is working, but seems really hacky. Is there a class or something I can add to make it "tabbable"?

Here's the navbar as it was before I added that routerLink="":

<ul class="nav navbar-nav">
    <li><a routerLink="/dashboard" routerLinkActive="active">Dashboard </a></li>
    <li><a routerLink="/studentaccount" routerLinkActive="active">My Account</a></li>
    <li><a routerLink="" (click)="logout()">Sign Out</a></li>
</ul>
like image 214
Alex Kibler Avatar asked Sep 13 '25 01:09

Alex Kibler


1 Answers

Adding tabindex="0" should solve it. E.g.

<a routerLink="/dashboard" routerLinkActive="active" tabindex="0">
like image 116
James King Avatar answered Sep 15 '25 14:09

James King