Wednesday 16 August 2017

how to check if Checkbox is checked or not using jQuery

Check if a CheckBox is checked or not using jQuery

Description:


In this example we explain that how to check if Checkbox is checked or not using jQuery. Or how to get the value of the Checkbox using jQuery. Or how to check or unchecked the Checkbox using jQuery. Or how to check if Checkbox is select or deselect using jQuery. Or how to check if Checkbox is selected or not selected using jQuery.
Code:

<label for="chkLicence">
    <input type="checkbox" id="chkLicence" />
    Do you have Licence?</label>
<br />
<br />
<input type="button" id="btnCheck" value = "Check" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
        $("#btnCheck").click(function () {
            var isChecked = $("#chkLicence").is(":checked");
            if (isChecked) {
                alert("CheckBox checked.");
            } else {
                alert("CheckBox not checked.");
            }
        });
    });
</script>



0 comments:

Post a Comment