banner

How to read a checkbox status using jQuery?

Check boxes are very common in HTML forms and is used to get multiple options.

How can we read a checkbox field or how to check whether a checkbox field is checked or not.

We can do it with the help of jQuery. If your HTML document is jQuery enabled you can use the following way.

<script>
$(document).ready(function () {
$("#checkbtn").click(function () {
if ($('#check1').is(':checked')) {
alert("checked");
} else {
alert("not checked");
}
});
})
</script>
<input type='checkbox' id='check1' />
<input type='button' id='checkbtn' value='check' />

So, $(‘#checkbox’).is(‘:checked’) will returun a true if check box is checked else it return a false value

0

Article Categories:
HTML & CSS · JavaScript · Programming · Web
Likes:
0

Leave a Comment

Your email address will not be published. Required fields are marked *