How to change the checkbox value using jQuery ? Last Updated : 03 Aug, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report The Checkboxes are used to let a user select one or more options for a limited number of choices. The :checkbox selector selects input elements with type checkbox.Syntax: $('#textboxID').val($("#checkboxID").is(':checked')); In the above syntax, basically the return value of the checked or unchecked checkbox is being assigned to the textbox. Below examples will illustrate the approach:Example 1: Here the return value of the checkbox is assigned to the textbox with a function click() whenever the checkbox is clicked to check or uncheck, it assigns the respective return value into the textbox. So, if we want to assign a certain user-defined value in the textbox according to check then we can do that with the use of if/else statement. html <!DOCTYPE html> <html> <head> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script> <script> $(document).ready(function() { // Set initial state $('#textbox2').val($(this).is(':checked')); // It gets checked to false as uncheck // is the default $('#checkbox1').click(function() { $('#textbox2').val($(this).is(':checked')); }); }); </script> </head> <body> <center> <h1 style="color:green;"> GeeksforGeeks </h1> <p> A Computer Science Portal for Geeks </p> <input type="checkbox" id="checkbox1" /> Check if true, Uncheck if false. <br><br> <input type="text" id="textbox2" /> </center> </body> </html> Output: Example 2: This example contains more than one checkboxes. javascript <!DOCTYPE html> <html> <head> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"> </script> <script> $(document).ready(function() { // Set initial state $('#textbox1').val('no'); // Returns yes or no in textbox1 // when checked and unchecked $('#checkbox1').click(function() { if ($("#checkbox1").is(":checked") == true) { $('#textbox1').val('yes'); } else { $('#textbox1').val('no'); } }); // Returns male in textbox2 if checkbox2 checked. $('#checkbox2').click(function() { if ($('#checkbox2').is(":checked") == true) { $('#textbox2').val('Male'); } else { $('#textbox2').val(''); } }); // Returns female in textbox2 // if checkbox2 checked. $('#checkbox3').change(function() { if ($('#checkbox3').is(":checked") == true) { $('#textbox2').val('Female'); } else { $('#textbox2').val(''); } }); }); </script> </head> <body> <center> <h1 style="color:green"> GeeksforGeeks </h1> <p> A Computer Science Portal for Geeks </p> <input type="checkbox" id="checkbox1" /> Check If yes! <br> <input type="text" id="textbox1" /> <br> <input type="checkbox" id="checkbox2" /> Male <input type="checkbox" id="checkbox3" /> Female <br> <input type="text" id="textbox2" /> </center> </body> </html> Output: jQuery is an open source JavaScript library that simplifies the interactions between an HTML/CSS document, It is widely famous with it's philosophy of “Write less, do more". You can learn jQuery from the ground up by following this jQuery Tutorial and jQuery Examples. Comment More infoAdvertise with us Next Article How to Check/Uncheck the checkbox using JavaScript ? T Tejashwi5 Follow Improve Article Tags : JQuery jQuery-Misc Similar Reads How to hide the checkbox based on value in jQuery? The checkbox is used to set the content according to the user which he wants to see at the interface. Users also can set multiple choices according to their wishes.Syntax:$('input[name=foo]').attr('checked', false);ApproachIntegrate jQuery in HTML file via CDN Links. Includes the necessary title. Ad 2 min read How to make a Themed Checkbox using jQuery Mobile ? jQuery Mobile is a web based technology used to make responsive content that can be accessed on all smartphones, tablets and desktops. In this article, we will be creating a Themed Checkbox using jQuery Mobile. Approach: Add jQuery Mobile scripts needed for your project. <link rel=âstylesheetâ hr 1 min read How to Check a Checkbox with jQuery? We can directly select the element by it's selector and then we can use checked property on that for check and unchecked. 1. By using Checked PropertyIn this method, we will select the element using the element selector and directly use the checked property on the item that is present at the passed 3 min read How to change Selected Value of a Drop-Down List using jQuery? We will change the default selected value of the dropdown using jQuery. In an HTML select tag, the default selected value is the value given to the first option tag. With jQuery, it is easy to change the selected value from a drop-down list. Below are the methods to change the selected value of a dr 3 min read How to Check/Uncheck the checkbox using JavaScript ? To check and uncheck the checkbox using JavaScript we can use the onclick event to toggle the checkbox value. We can also check or uncheck all the checkboxes on loading the webpage using JavaScript onload function.In this article, we will learn how to check/uncheck the checkbox using JavaScript. As 3 min read How to find all checkbox inputs using jQuery ? The task is to find all the checkbox input using jQuery. Checkboxes are the square boxes that are ticked when activated, and it is used to select one or more number of choices. Method and Selectors used: :checkbox: This selector is used to select the input element with type = checkbox. .wrap(): This 2 min read Like