0 votes
558 views
asked 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
answered 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 1.2k views
+1 vote
1 answer 7.8k views
asked May 10, 2017 in Jquery by Jasna
0 votes
1 answer 5.2k views
+1 vote
1 answer 771 views
...