@evgenin

Как проверить выбран input type radio на javascript?

<input id="height_1" type="radio">
<label id="height_lb_1" for="height_1" >Опция 1</label>

<input id="height_2" type="radio">
<label id="height_lb_2" for="height_2" >Опция 2</label>

<input id="height_3" type="radio">
<label id="height_lb_3" for="height_3" >Опция 3</label>


<!-- Связанные опции -->

<input id="hg_1" type="radio">
<label id="hg_lb_1" for="hg_1" >Связанная опция 1</label>

<input id="hg_2" type="radio">
<label id="hg_lb_2" for="hg_2" >Связанная опция 2</label>

<input id="height_3" type="radio">
<label id="hg_lb_3" for="hg_3" >Связанная опция 3</label>


В зависимости от того, какая связанная опция выбрана, скрывать или открывать (display none) первые группы опций?
  • Вопрос задан
  • 2903 просмотра
Решения вопроса 1
YumeReaver
@YumeReaver
Бургомистр
<label class="radio-inline"><input onchange="react()" type="radio" name="long_term" value="0" checked>No</label>
<label class="radio-inline"><input onchange="react()" type="radio" name="long_term" value="1">Yes</label>

function react() {
            isHidden = document.querySelector('input[name="long_term"]:checked').value;
            if (isHidden) {
            $("#block").show();
            }
}
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы