我希望使用Javascript而不是Jquery通过标签类获取输入值。我的HTML代码如下:
<label class="btn btn-secondary button-calculator">
<input type="radio" name="units[]" id="units1" value="1" autocomplete="off"> US units
</label>
<label class="btn btn-secondary button-calculator active">
<input type="radio" name="units[]" id="units2" value="2" autocomplete="off" checked=""> Metric units
</label>
我已经尝试过
document.getElementsByClassName("active").children
并且
document.getElementsByClassName("active").value
我一直在检查console.log的值,但是我没有得到任何有用的信息。
提前感谢您。
active
类,我认为这是OP想要的,除非我在问题中误解了什么 - undefined