JQuery to uncheck all checkboxes within div

前端 未结 2 912
天涯浪人
天涯浪人 2021-02-12 12:37
提交评论

  • 2021-02-12 13:12

    Another approach would be:

    Assign a class(just to use as a selector) to each checkbox,

    <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 />
    

    And use below line to check all checkboxes:

    $('.chk').attr("checked", true);
    

    For deleting, I guess you want to delete checkbox along with the title. Insert them into a div with some id. And remove that div:

     <div id="someid"><input type="checkbox" class="chk" name="SummaryInformation">Summary Information</div> 
    

    Use below code to delete:

    $('#someid').remove()
    

    This will remove checkbox as wel as the text since the div is removed.

    0 讨论(0)
  • 提交回复
    热议问题