I am trying to implement a checkbox as a button as described here:
I am trying to listen to the the change event of the underlying checkbox so I can do foo(), however the event is not firing, see my jsFiddle here:
Here's my code:
<div class=''>
<div class="hideComplete btn-group" data-toggle="buttons" >
<label class="btn btn-primary btn-sm" id="hideCompleteLabel">Hide completed
<input type="checkbox" id="hidecomplete"/>
</label>
</div>
</div>
<script>
$('#hidecomplete').on('change', function () {
if ($(this).is(':checked')) {
alert("I'm checked")
} else {
alert("I'm not checked")
}
});
</script>
Aucun commentaire:
Enregistrer un commentaire