对于示例jQuery,一页中有几个…标记
Js/jquery.js
Js/jquery-2.js
Js/jquery-3.js由于同时发生故障,所以不能同时使用所有的.js标记。
我创建了3个类似于这个…的复选框
<input name="jquery" type="checkbox" value="jquery">
<input name="jquery-2" type="checkbox" value="jquery-2">
<input name="jquery-3" type="checkbox" value="jquery-3">我喜欢的是当选中这些复选框中的任何一个并被禁用时,所以对于示例…。我检查了jquery和jquery-2,而不检查jquery-3。
我的问题是,当选中jquery时,如何编写代码到,从文件中禁用jquery。
非常感谢。
发布于 2017-03-06 18:49:03
假设您希望复选框在一个组中运行(选择1取消检查所有其他复选框),您可以这样做:
let checkBoxes = $("[name^=jquery]")
// Listen to changes on all checkBoxes, ignore the current element and uncheck all else
// Make sure to use jQuery 1.6+
checkBoxes.change(function(e) {
const me = this;
checkBoxes.not(me).prop('checked', false).removeAttr('checked')
})https://stackoverflow.com/questions/42633103
复制相似问题