E
E
Eugene Simon2018-02-23 15:59:22
JavaScript
Eugene Simon, 2018-02-23 15:59:22

How to make a selection and apply actions?

How to apply an action to a parent element under a certain condition... I don't understand how to explain correctly. In general, there are several filters on the site, by default they are closed and the first item is selected for each filter. When another item is selected, a class is added to it, and the label is removed from the first item. The idea is that the filters will be opened if the child links have other than the first checked class.
I will give my working script, it only works correctly for the first block with a filter, and for the other following it works partially incorrectly.

$(function(){
    $(".filter_group .filter_item:not(:first) a.checked").parents(".filter_group").css("display","block");
});

That is, the first block will be open if we have selected any option. So I need it. But the rest are also open, although I wrote in the function that the display block is applied to the parent block only if the .filter_item element has a checked class, except for the first one.
I'm confused and don't understand. Sorry for the confusing question.
Help with advice ... The filter can be seen at the link

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene Simon, 2018-09-21
@Comers

Made with css, just forgot how

A
Anton fon Faust, 2018-02-23
@bubandos

Post your code on jsfiddle.net so it's clear what's wrong.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question