我有以下表格:
<form>
<input type="radio" name="group-stack" value="grouped" checked>grouped<br>
<input type="radio" name="group-stack" value="stacked">stacked
</form>
我想使用 d3 获取当前选中的单选按钮的值。
以下尝试均未成功:
var val = d3.select('input[name="group-stack"]').checked; //undefined
var val = d3.select('input[name="group-stack"][checked]')[0][0].value //always 'grouped' regardless of which radio is selected
最佳答案
试试这个
d3.select('input[name="group-stack"]:checked').node().value
关于javascript - 使用 d3.js 获取选中的单选按钮的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29325040/