我想知道如何获取JavaScript中单选按钮组中的所有检查值。 我有一个对象,每个对象都有两个具有动态ID和名称的单选按钮组,如何获取单选的检查值 javascript中数组中的按钮而不是jquery
return obj.map.function((e)=>{
<div class="form-check pb-2">
<input class="form-check-input" name="send-${provider.id}" type="radio" id="provider-send-bank-${provider.id}" value="bank" checked>
<input class="form-check-input" name="send-${provider.id}" type="radio" id="provider-send-credit-${provider.id}" value="credit">
<input class="form-check-input" name="send-${provider.id}" type="radio" id="provider-send-debit-${provider.id}" value="debit">
</div>
})
// map will return as shown below
<div class="form-check pb-2">
<input class="form-check-input" name="send-trans" type="radio" id="provider-send-bank-trans" value="bank" checked>
<input class="form-check-input" name="send-trans" type="radio" id="provider-send-credit-trans" value="credit">
<input class="form-check-input" name="send-trans" type="radio" id="provider-send-debit-trans" value="debit">
</div>
<div class="form-check pb-2">
<input class="form-check-input" name="send-fund" type="radio" id="provider-send-bank-fund" value="bank" checked>
<input class="form-check-input" name="send-fund" type="radio" id="provider-send-credit-fund" value="credit">
<input class="form-check-input" name="send-fund" type="radio" id="provider-send-debit-fund" value="debit">
</div>
Expected Output:
// if radio with name `send-trans` credit option is checked & if radio with name `send-fund` is checked
[credit, debit]