C
C
cjkfdt2017-09-15 19:44:15
Angular
cjkfdt, 2017-09-15 19:44:15

How to make it so that when a link is clicked, the active class is added to it, while it is removed from others?

There is a list of links:

<a class="active" hrref="#">Href 1</a>
<a hrref="#">Href 2</a>
<a hrref="#">Href 3</a>

How to make it so that when you click on any of these links, the active class is added to it, and it is removed from others?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
ozknemoy, 2017-09-16
@ozknemoy

for the first angular if ui-router is used then

<a  ui-sref-active="active" ui-sref="user.about">Информация</a>

for the second
<a routerLink="earning" routerLinkActive="active">заработок</a>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question