【问题标题】:How to Clear checkbox When checked other checbox ? using java script [duplicate]检查其他复选框时如何清除复选框?使用 javascript [重复]
【发布时间】:2014-09-13 02:23:00
【问题描述】:

选中其他复选框时如何清除复选框?使用java脚本

当用户选中复选框 id="checkItem1"id="checkItem2"id="checkItem3" 我想清除复选框 id="checkAll" 我该怎么做?使用java脚本

<input type="checkbox" id="checkAll" checked > Check All
    <hr />
    <input type="checkbox" id="checkItem1"> Item 1
    <input type="checkbox" id="checkItem2"> Item 2 
    <input type="checkbox" id="checkItem3"> Item 3

http://jsfiddle.net/peap/sydzL8Lc/8/

【问题讨论】:

标签: javascript jquery checkbox


【解决方案1】:

使用jQuery,你可以写:

$("#checkItem1").click(function() {
    $("#checkAll").prop('checked', false);
});

然后对checkItem2checkItem3 重复此操作。但我建议为所有checkItems 添加一个类,这样会更容易选择它们。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多