This question already has an answer here:
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="http://ift.tt/1oMJErh"></script>
<div class="getcheckbox">
</div>
<button class="btn-check">Add Checkbox</button>
Aucun commentaire:
Enregistrer un commentaire