@rocky_mounted

Не работает переключение input-ов radio. В чём может быть проблема?

Кастомизировала radio input-ы и почему-то не работает переключатель. Проверила уже всё на 100 раз. В чём может быть проблема?

<div class="content">
      <div class="content-item">
        <input class="content-radio-btn" type="radio" id="radioBtn" name="one">
        <label class="content-item-label" for="one">license plan #1</label>
        <span class="content-item-text">$13 per license</span>
      </div>
      <div class="content-item">
        <input class="content-radio-btn" type="radio" id="radioBtn" name="two">
        <label class="content-item-label" for="two">license plan #2</label>
        <span class="content-item-text">$22 per license</span>
      </div>
      <div class="content-item">
        <input class="content-radio-btn" type="radio" id="radioBtn" name="three">
        <label class="content-item-label" for="three">license plan #3</label>
        <span class="content-item-text">$34 per license</span>
      </div>
  </div>


.content {
  padding: 20px;
}

.content-item {
  position: relative;
}

.content-item-label {
  padding-left: 30px;
  text-transform: uppercase;
  font-family: 'BebasBold';
  color: #929495;
  font-size: 20px;
  cursor: pointer;
}

.content-item-label::before {
  content: '';
  display: block;
  width: 16px;
  height: 16px;
  border: 3px solid #34648e;
  background-color: transparent;
  border-radius: 50%;
  position: absolute;
  top: -3px;
  left: 0;
  z-index: 1;
}

.content-item-label::after {
  content: '';
  display: block;
  width: 10px;
  height: 10px;
  background-color: #0294bf;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 6px;
  opacity: 0;
  z-index: 2;
}

.content-item-text {
  position: absolute;
  right: 0;
  color: #929495;
}



.content-radio-btn {
  display: none;
}

.content-radio-btn:checked + .content-item-label::before {
  background-color: #fff;
  border-color: #ffff;
}

.content-radio-btn:checked + .content-item-label::after {
  opacity: 1;
}
  • Вопрос задан
  • 183 просмотра
Решения вопроса 1
0xD34F
@0xD34F Куратор тега CSS
У input'ов атрибуты id и name перепутаны.
Ответ написан
Пригласить эксперта
Ответы на вопрос 1
Fortoo
@Fortoo
Top-Web OpenCart
Чтобы input-ты переключались зависимо, должны быть одинаковые name
<input type="radio" name="one"><br>
<input type="radio" name="one"><br>
<input type="radio" name="one">


А если name разные, то использовать js
<input type="radio" name="one"><br>
<input type="radio" name="two"><br>
<input type="radio" name="three">

$('input[type="radio"]').on('click', function() {
  $('input[type="radio"]').prop('checked', false);
  $(this).prop('checked', true);
});
Ответ написан
Комментировать
Ваш ответ на вопрос

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

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