#productivity
#webdevelopment
#jquery
#checkbox

How can i check whether a checkbox is checked in jQuery

Anonymous

AnonymousJan 07, 2024

In this posts, we will see How can i check whether a checkbox is checked in jQuery ?

jQuery is a feature-rich, compact, and speedy JavaScript library. With an intuitive API that functions in a wide range of browsers, it greatly simplifies tasks like HTML document traversal and manipulation, event handling, animation, and Ajax. Because of its adaptability and extensibility, jQuery has revolutionised the way that millions of JavaScript writers write their code.

Lets assume, You have checkbox in html:

<input type="checkbox" id="myCheckbox"> Check me!

Now, Here's a code to check if that checkbox is checked or not:

$(document).ready(function () {
  if ($('#myCheckbox').is(':checked')) {
    console.log('Checkbox is checked!');
  } else {
    console.log('Checkbox is not checked');
  }
});

Happy Coding! ❤️