[英]I need help to get the Name of radio button using JavaScript not the value
嗨,我在 HTML 下面使用单选按钮问题有不同的选项具有不同的值
<div class="form-check-inline section-3">
<input class="form-check-input" type="radio" name="question1" id="gridRadios1" value="1">
<label class="form-check-label" for="gridRadios1">
Never
</label>
</div>
您将看到单选按钮的值为“1”,但在出现问题时屏幕上显示“从不”....当我使用$("input[name='question1']:checked").val();
我得到的值是 1,但我想要“从不”的文本如何得到它....
let $input = $("input[name='question1']:checked");
$input.siblings(`label[for='${$input.attr('id')}']`).text();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.