checkbox default value and checked value get in jquery 1

checkbox default value and checked value get in jquery

//selected checkbox alert boolen value return
$('#test').click(function() {
    alert("Checkbox state (method 1) = " + $('#test').prop('checked'));
    alert("Checkbox state (method 2) = " + $('#test').is(':checked'));
});

Check me: 
  //@sujaY

Here is what the above code is Doing:
1. When the checkbox is clicked, the function is called.
2. The function checks the state of the checkbox using the prop() method.
3. The function checks the state of the checkbox using the is() method.
4. The function displays the state of the checkbox using the alert() method.

Similar Posts