Добавить и удалить класс элементу по клику в цикле php
Вот коды которые у меня есть Вот html с php:
```<?$res = mysqli_query($con,"SELECT * FROM menu");
$row = mysqli_fetch_assoc($res);
do{
$href = $row['title'];
if( $href == 'Home'){
$href = 'index';
}
if( $href == 'Contact Us'){
$href = 'contact';
}
?>
<a href="<?=$href?>.php" id="ahref" class="active"><?=$row['title']?>
<? }while($row = mysqli_fetch_assoc($res));?>
Вот javascript:
Вот css:
#templatemo_menu ul li a {
float: left;
display: block;
width: 100px;
height: 26px;
margin: 0 20px 0 0;
padding: 5px 0 0 0;
font-size: 12px;
text-align: center;
text-decoration: none;
color: #e4e1e1;
font-weight: bold;
outline: none;
border: none;
}
#templatemo_menu ul li a:hover, #templatemo_menu ul li .current {
color: #fff;
background: url(images/templatemo_menu_hover.jpg) center bottom no-repeat;
}```
Помогите, нужно чтобы при клике добавился класс current к нажатому
PS так как меню в цикле приходится делать операцию через js