0

I am inserting checkbox using JQuery. When a user click "Add Checkbox" button, the checkbox appears. Now once the user selects this checkbox, I want to get the details i.e value or text of that particular checkbox. How to do that ?

$(document).ready(function() {
  $('.btn-check').click(function() {
    $('.getcheckbox').append('<input class="check-box" type="checkbox" name="vehicle" value="Bike"> I have a bike<br>');
  });

  $('.check-box').change(function() {
    if ($(this).is(':checked')) {
      console.log("tick");
    }
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="getcheckbox">

</div>
<button class="btn-check">Add Checkbox</button>
Shubham Sinha
  • 79
  • 2
  • 12

0 Answers0