Reputation: 1
So i have this code
<li>
<a href="./home.php"></a>
</li>
I want to add class active to <li>
But i want to add this class by selecting <a>
with href ="./home.php"
get to it's parent <li>
and add class active.
The final code will look like this
<li class="active">
<a href="./home.php"></a>
</li>
Upvotes: 0
Views: 2034
Reputation: 122057
Try this DEMO
$('a[href="./home.php"]').parent('li').addClass('active');
Upvotes: 1