隐藏div时jQuery清除复选框?

Sou*_*aby 1 checkbox jquery

我有一个jQuery脚本,它将根据选择的选项显示特定的div.

这是代码:

jQuery.noConflict();
jQuery(document).ready(function() {
  jQuery.viewMap = {
    '' : jQuery([]),
    '1' : jQuery('.company_1'),
    '2' : jQuery('.company_2')
  };
  jQuery('#companyid').change(function() {
    jQuery.each(jQuery.viewMap, function() { this.hide(); });
    jQuery.viewMap[jQuery(this).val()].show();
  });
});
Run Code Online (Sandbox Code Playgroud)

(示例div)

<div class="company_1" style="display: none;">
  <input type="checkbox" name="classifications[Miner]" id="classifications[Miner]" /> Spec/Rough
  <input type="checkbox" name="classifications[Dealer]" id="classifications[Dealer]" /> Dealer
</div>
Run Code Online (Sandbox Code Playgroud)

如果有人选择其他选项,我希望清除div(.company_1,.company_2等)中的所有复选框.如果这有道理?:)

谢谢!

Ken*_*ing 10

取消选中复选框是通过删除名为"已检查"的属性来实现的.尝试:

jQuery.each(jQuery.viewMap, function() {
    this.hide();
    jQuery('input:checkbox', this).removeAttr('checked');
});
Run Code Online (Sandbox Code Playgroud)