0 votes
4.0k 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 16.9k views
+1 vote
1 answer 3.8k views
+1 vote
1 answer 10.3k views
asked May 11, 2017 in Jquery by Jasna
0 votes
1 answer 1.6k views
0 votes
1 answer 946 views
asked Jan 26, 2022 in Jquery by Singer
0 votes
1 answer 8.8k views
asked Mar 5, 2018 in General by mithun (1.3k points)
...