Below code snippet helps you find the status of your checkbox.
i.e. - Many times you need to find out whether your checkbox is CHECKED or UNCHECKED.
Here's how you can find it !!!
i.e. - Many times you need to find out whether your checkbox is CHECKED or UNCHECKED.
Here's how you can find it !!!
Script
- var checkedStatus = function () {
- var atLeastOneIsChecked = $('input[name="chk[]"]:checked').length > 0;
- if (atLeastOneIsChecked)
- $('.status-value').text("Checked");
- else
- $('.status-value').text("UnChecked");
- };
- checkedStatus();
- $("input[type=checkbox]").on("click", checkedStatus);
HTML
- <div class="status">
- <input type="checkbox" name="chk[]" value="Demo Box" />
- <div class="status-value"></div>
- </div>
No comments:
Post a Comment