mercredi 24 janvier 2018

How to display the value of the future checkbox element?

I'm appending multiple checkbox like this:

$(".btn-sample").on("click", function() {
  $(".container").append(
    '<input class="check-sample" type="checkbox" 
    value="'+check_value+'"/>'
  );
});

My problem is that my other button cannot get the value of the new checkbox by click this button below:

 $(".show-checkbox").click(function() {
   var arr = [];
   $('.check-sample:checked').each(function () {
       arr[i++] = $(this).val();
   });
   console.log(arr);
 });

Thank for helping in advance!




Aucun commentaire:

Enregistrer un commentaire