mardi 30 août 2016

Click on the checkbox inside div which changes the state of the checkbox. jQuery

Can someone help me with this problem?

$('.check_group').click(function () {
    var check = $(this).children('input')[0];
    check.checked = !check.checked;
    alert(check.checked);
    //run something else
});
<script src="http://ift.tt/1qRgvOJ"></script>
<div class="check_group" style="background-color: rgb(200, 138, 59);">
  <input type="checkbox" />
</div>

So, when I click on the checkbox - change the state of the checkbox, and then triggered jQuery and status changes back.

How to make so that when you click on the div / Checkbox - checkbox has changed and there is an alert?




Aucun commentaire:

Enregistrer un commentaire