0 votes
3.7k views
in Jquery by
Find all parent elements (in my case its all parent "<li>" elements) with Jquery. Idea is to set active classes for my dropdown menu.

Can I do this with "parents" Jquery filter?

1 Answer

0 votes
by
Supply $(this) to the code below and you are good to go. Change the css code to your requirements as well.

$(this).parents('li').add(this).each(function()
{
$(this).css({"color": "red", "border": "2px solid red"});
});

Related questions

0 votes
1 answer 15.6k views
+1 vote
1 answer 3.5k views
+1 vote
1 answer 10.0k views
asked May 11, 2017 in Jquery by Jasna
0 votes
1 answer 788 views
0 votes
1 answer 527 views
asked Jan 26, 2022 in Jquery by Singer
0 votes
1 answer 8.5k views
asked Mar 5, 2018 in General by mithun (1.3k points)
...