我正在编写一个表单,它具有复选框,并且我编写了一个脚本来显示和隐藏它们(特别是在选中其中一个复选框时,隐藏所有其他复选框)。
当我需要它来隐藏输入复选框时,我已经走到了这一步,但是下面的代码正在做的是:它仅显示一个复选框(第二个)。为什么,如何同时隐藏两个复选框?

$('input:checkbox.individual' && 'input:checkbox.organization').stop(true,true).fadeIn("normal")


这是我的HTML:

                <div class="field check check-entity">
                    <label for="entity_type">For what kind of entity are you requesting sponsorship?<span class="form_required">*</span></label><br><br>
                    <input type="checkbox" name="entity_type" value="entity_project" class="project"/><label for="entity_project" class="lalbe_project">Project</label>
                    <input type="checkbox" name="entity_type" value="entity_individual" class="individual"/><label for="entity_individual"class="label_individual">Individual</label>
                    <input type="checkbox" name="entity_type" value="entity_organization" class="organization"/><label for="entity_organization" class="label_organization">Organisation</label>
                </div>

最佳答案

在选择字符串中使用,选择多组元素

$('input.individual:checkbox, input.organization:checkbox')
//                          ^ see here

10-04 22:49
查看更多