Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. SQL Server
  3. Question
SQL Server

Get checkbox value in jQuery

Asked by Abigail Abraham Nov 30, -0001 329 views 2 answers
Share

About this question

How can I get a checkbox's value in jQuery?

Your answer

2 Answers

Claude Holloway Latest answer

Answered on Nov 12, 2024

In jQuery, you can get the value of a checkbox (whether it's checked or unchecked) using the .prop() method for the checked property, or you can use .is() for a boolean check.  The .prop() method is generally preferred when you want to check or set properties like checked for form elements.

Check me




[removed][removed]

[removed]

$(document).ready(function() {

  $('#checkButton').click(function() {

    var isChecked = $('#myCheckbox').prop('checked');

    if (isChecked) {

      console.log('Checkbox is checked');

    } else {

      console.log('Checkbox is unchecked');

    }

  });

});

[removed]

Check out our site basketball random for more information. 

Was this helpful?

Abigail Abraham

Answered on Jun 21, 2021

Was this helpful?

More SQL Server discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest SQL Server Blogs

Guides, tips and career advice on SQL Server from JanBask experts.