我有一组可以切换的类。代码是这样的:
$(".form-btn").click(function(event) {
event.preventDefault();
$(this).next().toggle(0);
});
使用 HTML 如下:
<div class="form-btn-wrapper">
<div class="form-btn" id="buy-or-rent">Buy or Rent <i class="icon-caret-down"></i></div>
<div class="form-popup radio">
<input id="check1" type="radio" name="buy-or-rent" value="To Buy">
<label for="check1">To Buy</label>
<input id="check2" type="radio" name="buy-or-rent" value="To Rent">
<label for="check2">To Rent</label>
</div>
</div>
<div class="form-btn-wrapper">
<div class="form-btn" id="price">Price <i class="icon-caret-down"></i></div>
<div class="form-popup">
<input type="text" name="min-price" class="small price-input" placeholder="Min" /> to <input type="text" name="max-price" class="small price-input" placeholder="Max" />
</div>
</div>
这可以正常工作,但要关闭每个切换(表单弹出),您必须再次单击其各自的表单-btn。如何更改 jquery 以便在单击任意位置时关闭表单弹出窗口?
谢谢