Greetings, comrades! There is such a markup:

<ul class="form__list form__list"> <li class="form__checkbox-wrapp"> <input type="radio" name="capital" id="capital1"> <label for="capital1">up to $25 000</label> </li> <li class="form__checkbox-wrapp"> <input type="radio" name="capital" id="capital2" checked> <label for="capital2">up to $100 000</label> </li> <li class="form__checkbox-wrapp"> <input type="radio" name="capital" id="capital3"> <label for="capital3">up to $500 000</label> </li> <li class="form__checkbox-wrapp"> <input type="radio" name="capital" id="capital4"> <label for="capital4">over $1 000 000</label> </li> <li class="form__checkbox-wrapp"> <input type="radio" name="capital" id="capital5" class="js-checked-capital"> <label for="capital5">Другое</label> </li> </ul> <div class="form__input-wrapp form__input-wrapp--hidden js-show-capital"> <input type="text" placeholder=""> </div> 

And such a JS:

 var inpCheckbox = $('.js-checked-key'), showInpOne = $('.js-show-key'), inpRadio = $('.js-checked-capital'), showInpTwo = $('.js-show-capital'); function checkedInput(check, visible) { check.click(function () { if (check.is(':checked')) { visible.addClass('js-inp-visible'); } else{ visible.removeClass('js-inp-visible'); } }) } checkedInput(inpCheckbox, showInpOne); checkedInput(inpRadio, showInpTwo); 

So, for checkboxes, this code works out and the hidden input appears on the screen, and for the radiobutton adds a class to the hidden input, shows it, but when I remove the checked status from the last radio, the hidden input still remains. Tell me, please, what is the matter and how to solve it?

  • "when I remove the status from the last radio with the state" - how? - Igor
  • I put the checker on another radio button - Oleg
  • You understand that when you click on one of the first four radio buttons, no click on .js-checked-capital occurs. - Igor
  • I understood my mistake, thanks for the hint) - Oleg

0