I have a jQuery menu with state but I am getting a small problem.
Now my code is working in all <li>
, but should be different for each <li>
because will be a menu with different icons.
so for example fa-bars when is clicked need to have color yellow, but when fa-search is clicked need to have color red I need apply this for the <li>
because I need change the li
background.
so basicly what I am try to do is: when click first time be yellow and when i click second time back to the original color.
that applying for each fa icon understand?
jsfiddle: https://jsfiddle.net/oosa8yzk/4/
html:
<ul>
<li>
<a class="menu" data-toggle="tooltip" data-placement="bottom" title="home">
<i class="fa fa-bars fa-2x" aria-hidden="true"></i>
</a>
</li>
<li>
<a class="search"><i class="fa fa-search fa-2x" aria-hidden="true"></i></a>
</li>
</ul>
jquery
$(document).ready(function() {
$('li a').on('click', function() {
$('li').removeClass('active');
$('li').addClass('active');
});
});
css:
.active {
color: blue;
background-color: red;
}
.active .fa {
color: yellow;
}