Skip to content Skip to sidebar Skip to footer

Identify Which Checkbox Was Clicked

I have a set of checkboxes on my page. Code for one of them:

Solution 1:

Try this

$('input.enable-checkbox').on('click', function (e) {
    $(this).closest('label').val(this.checked);   
})

Solution 2:

first you should give IDs to your checkboxes themselves. then:

$("#idCheckbox1").change(function(){
   if($("#idCheckbox1").attr('checked')){
       $("#ViewAsWebPage").val("true")
   }
}

$("#idCheckbox2").change(function(){
   if($("#idCheckbox2").attr('checked')){
       $("#ViewAsWebPage").val("false")
   }
}

Post a Comment for "Identify Which Checkbox Was Clicked"