lundi 22 août 2016

How can I work only with siblings in jQuery?

How can I accomplish this, let's say I have this checklist created dynamically in htlm. What I want is if I create exact same checklist with .append() and press button add-item it will trigger only that button which is clicked not both of them?

<div class="checkbox">
   <input id="check1" type="checkbox" name="check" />
   <label for="check1"><span class="chk-text">Checklist One<span></label>
     <br>
   <input id="check2" type="checkbox" name="check" checked>
   <label for="check2"><span class="chk-text">Checklist two<span></label>
     <br>
   <input id="check3" type="checkbox" name="check">
   <label for="check3"><span class="chk-text">Checklist three<span></label>
   </div> <!-- END OF CHECKBOX -->
   <button class="add-item" type="button">Add</button>
</div> <!-- END OF ADD-ITEM -->

Aucun commentaire:

Enregistrer un commentaire