我有一个带复选框的div,每次检查其中任何一个之前我都要确保它们先被清除。有关如何做到这一点的任何意见?
由复选框组成的div的HTML代码是
<div class="row_bus_groups cuke_business_group">
<div class="row">
<input class="field_checkbox cuke_partners" type="checkbox" id="SelectedBusinessGroups[0]" name="SelectedBusinessGroups[0]" value="Partners">
<label for="SelectedBusinessGroups[0]"><span class="translated_text" rel="BusinessGroups.Partners">Partners</span></label>
<input type="hidden" name="SelectedBusinessGroups[0]" value="">
</div>
<div class="row">
<input class="field_checkbox cuke_press" type="checkbox" id="SelectedBusinessGroups[1]" name="SelectedBusinessGroups[1]" value="Press">
<label for="SelectedBusinessGroups[1]"><span class="translated_text" rel="BusinessGroups.Press">Press</span></label>
<input type="hidden" name="SelectedBusinessGroups[1]" value="">
</div>
</div>
我试过
@browser.div(:class, "cuke_business_group").checkbox.each{ |all| all.clear }
答案 0 :(得分:7)
你很亲密。试试这个:
@browser.div(:class => "cuke_business_group").checkboxes.each {|checkbox| checkbox.clear}