Related Post:
- Check if radio button is checked or selected using jQuery
- Common jQuery Mistakes
1. First Way:
Below single line of code will provide the status of checkbox using jQuery. It checks whether the checked is checked or not using jQuery and will return 1 or 0.
1 | var isChecked = $('#chkSelect').attr('checked')?true:false; |
So if you want to have true or false, then you need to use conditional expression as I have done in the code.
2. Second Way
1 | var isChecked = $('#chkSelect:checked').val()?true:false; |
3. Third Way
1 | var isChecked = $('#chkSelect').is(':checked'); |
4. Fourth Way
The below code is to find out all the checkbox checked through out the page.
1 | $("input[type='checkbox']:checked").each( |
2 | function() { |
3 | // Your code goes here... |
4 | } |
5 | ); |