我找不到解决这个的办法。
需要使用JavaScript对所选输入之前的输入和未选中的输入进行属性检查。
UPD:将输入类型更改为“复选框”,现在我需要一个在上次选中之前标记“选中”复选框的函数,同时取消选中后续复选框,以防之前选中它们。
注意:解决方案必须使用ES5兼容的语法。
有代码示例,请!
<input type="checkbox" id="product-1" name="toggle">
<input type="checkbox" id="product-2" name="toggle">
<input type="checkbox" id="product-3" name="toggle">
<input type="checkbox" id="product-4" name="toggle">
<input type="checkbox" id="product-5" name="toggle">发布于 2020-06-02 17:49:40
<input type="radio">的默认行为是只允许选择一个输入/选项。因此,只有最后一个输入被标记为您的JS代码。要能够选择多个选项,请使用<input type="checkbox">。更多参考:MDN文档。
https://stackoverflow.com/questions/62158086
复制相似问题