<div id="termSheetPopup">
<div style="text-align:center;">
<select id="termSheetType">
<option>Internal</option>
<option>Borrower Facing</option>
</select>
</div>
<input type="checkbox" name="SummaryInformation">Summary Information<br />
<input type="checkbox" name="ProductLegs">Product Legs<br />
<input type="checkbox" name="AmortizationOptions">Amortization Options<br />
<input type="checkbox" name="Values">Values<br />
<input type="checkbox" name="Rates">Rates<br />
<input type="checkbox" name="RatesSpecific">Rates (All-In-Rate, PV01)<br />
<input type="checkbox" name="AmortizationSchedule">Amortization Schedule<br />
<input type="checkbox" name="SponsorInfo">Sponsor/Affiliate Info<br />
<input type="checkbox" name="BorrowerInfo">Borrower Info<br />
<input type="checkbox" name="SponsorContacts">Sponsor/Affiliate Contacts<br />
<input type="checkbox" name="CashFlows">Cash Flows<br />
<input type="checkbox" name="PrePayment">Pre-Payment<br />
<input type="checkbox" name="FutureExposure">Potential Future Exposure<br />
<input type="checkbox" name="FutureExposureSpecific">Potential Future Exposure (Max Number and Date Only)<br />
<input type="checkbox" name="History">History<br />
</div>
什么是JQuery删除该div下面的所有复选框?
答案 0 :(得分:56)
取消选中所有复选框(如标题所示):
$('#termSheetPopup').find('input[type=checkbox]:checked').removeAttr('checked');
要删除所有复选框(如问题所示):
$('#termSheetPopup').find('input[type=checkbox]:checked').remove();
答案 1 :(得分:2)
另一种方法是:
为每个复选框分配一个类(仅用作选择器)
<div id="termSheetPopup">
<div style="text-align:center;">
<select id="termSheetType">
<option>Internal</option>
<option>Borrower Facing</option>
</select>
</div>
<input type="checkbox" class="chk" name="SummaryInformation">Summary Information<br />
<input type="checkbox" class="chk" name="ProductLegs">Product Legs<br />
<input type="checkbox" class="chk" name="AmortizationOptions">Amortization Options<br />
<input type="checkbox" class="chk" name="Values">Values<br />
<input type="checkbox" class="chk" name="Rates">Rates<br />
<input type="checkbox" class="chk" name="RatesSpecific">Rates (All-In-Rate, PV01)<br />
<input type="checkbox" class="chk" name="AmortizationSchedule">Amortization Schedule<br />
<input type="checkbox" class="chk" name="SponsorInfo">Sponsor/Affiliate Info<br />
<input type="checkbox" class="chk" name="BorrowerInfo">Borrower Info<br />
<input type="checkbox" class="chk" name="SponsorContacts">Sponsor/Affiliate Contacts<br />
<input type="checkbox" class="chk" name="CashFlows">Cash Flows<br />
<input type="checkbox" class="chk" name="PrePayment">Pre-Payment<br />
<input type="checkbox" class="chk" name="FutureExposure">Potential Future Exposure<br />
<input type="checkbox" class="chk" name="FutureExposureSpecific">Potential Future Exposure (Max Number and Date Only)<br />
<input type="checkbox" class="chk" name="History">History<br />
并使用以下行检查所有复选框:
$('.chk').attr("checked", true);
要删除,我想你要删除复选框和标题。将它们插入带有一些id的div中。并删除该div:
<div id="someid"><input type="checkbox" class="chk" name="SummaryInformation">Summary Information</div>
使用以下代码删除:
$('#someid').remove()
这将删除复选框以及文本,因为删除了div。