mardi 10 novembre 2015

jQuery: How to callback/restore after remove checkbox

This is my html code:

<div class="foo">
 <label class="checkbox-wrapper">
       One<input type="checkbox" value="1" />
 </label>
 <label class="checkbox-wrapper">
       Two<input type="checkbox" value="1" />
 </label>
 <label class="checkbox-wrapper">
       Three<input type="checkbox" value="1" />
 </label>
 <label class="checkbox-wrapper">
       Four<input type="checkbox" value="1" />
 </label>
</div>    

<button class="btn btn-default btn-block slight" id="allFinished">Remove checked</button>
<button class="btn btn-default btn-block slight" id="show">Show</button>

This is my jQuery Code:

$(document).ready(function(){
  $('#allFinished').on("click", function(){
      $(".checkbox-wrapper").each(function(){           
          if($(this).find("input[type=checkbox]").prop("checked")){ $(this).remove(); } 
      });
  });

  $('#show').on("click", function(){
      //I don't know what must I fill this
  });
});

I know how to remove the checkbox after check and click button. but I don't know how to restore it again? anybody can help me This demo from fiddle DEMO FIDDLE




Aucun commentaire:

Enregistrer un commentaire