Get checkbox value in jQuery

To get the checkbox value in jquery you have written some scripts like below.

$("input[type='checkbox']").val();

Or if you have set a class or id for it, you can:

$('#check_id').val();
$('.check_class').val();

However this will return the same value whether it is checked or not, this can be confusing as it is different from the submitted form behavior.

To check whether it is checked or not, do:

if ($('#check_id').is(":checked"))
{
  // it is checked
}
0 0 votes
Article Rating

Do you want to hire us for your Project Work? Then Contact US.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x