【发布时间】:2014-09-14 15:23:28
【问题描述】:
我有一个简单的选择/取消选择选项来选中和取消选中页面中的复选框。它运作良好,但只有一次。不知道是什么问题!
请看一下我的代码。你可以看到它的demo here。
HTML 代码:
<input type="checkbox" id="main" />Select All<br />
<input type="checkbox" class="options" />Item 1<br />
<input type="checkbox" class="options" />Item 2<br />
<input type="checkbox" class="options" />Item 3<br />
<input type="checkbox" class="options" />Item 4<br />
jQuery 代码:
$('#main').click(function(e) {
$('.options').attr('checked', this.checked);
});
【问题讨论】:
标签: jquery html checkbox html-select deselect