Having a variable that can contain ‘#tab1’..’#tab4′, How can I select and change the css style of the corresponding style.
For example: if my variable is tab2; I have only to change the style of the li that have <a href="#tab2">16 cm</a>
That’s my html code:
<ul class="tabs">
<li class="active"><a href="#tab1">12 cm</a></li>
<li><a href="#tab2">16 cm</a></li>
<li><a href="#tab3">19 cm</a></li>
<li><a href="#tab4">8 cm</a></li>
</ul>
Thanks for help.
You could simply select the a tags by the expected href and then move up to their parents: