S
S
Sergey Burduzha2020-04-28 18:45:58
JavaScript
Sergey Burduzha, 2020-04-28 18:45:58

Why does the element not appear on the page when clicked?

Good afternoon.
I want to implement select through input radio.

.filter
    .filter__form
        .filter__form-group
            h4.filter__title Tipologia
            .select
                .select__item
                    input(id="select1" type="radio" value="residentiali" name="residentiali" checked="checked")
                    label(for="select1") Residentiali
                .select__item
                    input(id="select2" type="radio" value="commerciali" name="commerciali")
                    label(for="select2") Commerciali
        .filter__form-group
            h4.filter__title Zona
            .select
                .select__item
                    input(id="select3" type="radio" value="tutte" name="tutte" checked="checked")
                    label(for="select3") Tutte
                .select__item
                    input(id="select4" type="radio" value="testo1" name="testo1")
                    label(for="select4") Testo1
        .filter__form-group
            h4.filter__title Contratto
            .select
                .select__item
                    input(id="select5" type="radio" value="vendita" name="vendita" checked="checked")
                    label(for="select5") Vendita
                .select__item
                    input(id="select6" type="radio" value="testo2" name="testo2")
                    label(for="select6") Testo2


input[type="radio"] {
    display: none;
    
    &:checked + label {
    display: block;
    }
  }


I set the select_item class to active to show the label.
&__item {
    &.active {
    label {
      display: block;
    }
    }
  }


And through javascript I want to set the class, but it does not appear.
let showSelect = function () {
    $('.filter__form .select').on('click', function () {
      let selectItem = $(this).find('.select__item');
      console.log(selectItem.hasClass('active'));

      if (selectItem.hasClass('active') === false) {
        selectItem.addClass('active');
      } else {
        selectItem.removeClass('active');
      }
    });
  };
  showSelect();


I've been trying for an hour now but I can't figure out why it's not working.

Below selects html-delisa.host1670806.hostland.pro

Thanks for the tip.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question