{"id":5170,"date":"2024-10-21T05:43:38","date_gmt":"2024-10-21T05:43:38","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=5170"},"modified":"2024-10-21T07:18:50","modified_gmt":"2024-10-21T07:18:50","slug":"how-to-set-checked-for-checkbox-in-jquery","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/","title":{"rendered":"How to Set Checked For Checkbox in jQuery"},"content":{"rendered":"\n<p>jQuery is a popular JavaScript library used by many web developers for DOM manipulation and client-side processing. Often JavaScript developers need to work with form elements such as checkboxes. They need to check if checkbox is checked and set it if not the case. There are 3 simple ways to easily set checked for checkbox in jQuery. In this article, we will learn how to do this.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#How_to_Set_Checked_For_Checkbox_in_jQuery\" >How to Set Checked For Checkbox in jQuery<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#1_Using_Checked_Property\" >1. Using Checked Property<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#2_Using_Prop_Method\" >2. Using Prop Method<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#3_Using_Attr_Method\" >3. Using Attr Method<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Set_Checked_For_Checkbox_in_jQuery\"><\/span>How to Set Checked For Checkbox in jQuery<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here are 3 different ways to programmatically check checkbox in jQuery.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Using_Checked_Property\"><\/span>1. Using Checked Property<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>jQuery provides <em>checked<\/em> property for all checkboxes. It can have true or false values &#8211; true means it is checked and false means it is unchecked. Here is its syntax.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$(element_selector).checked=true<\/pre>\n\n\n\n<p>Let us say you have the following 2 checkboxes.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;form action=\"\/test.php\"&gt;<br>  &lt;input type=\"checkbox\" id=\"apple\" name=\"apple\" value=\"apple\" class=\"fruits\"&gt;<br>  &lt;label for=\"apple\"&gt; Apple&lt;\/label&gt;&lt;br&gt;<br>  &lt;input type=\"checkbox\" id=\"banana\" name=\"banana\" value=\"banana\" class=\"fruits\"&gt;<br>  &lt;label for=\"banana\"&gt; Banana&lt;\/label&gt;&lt;br&gt;<br>&lt;\/form&gt;<\/pre>\n\n\n\n<p>If you want to check the checkbox with id=&#8217;apple&#8217; then you can do this using the following code.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$('#apple').checked=true<\/pre>\n\n\n\n<p>In the above code, we use the ID attribute to uniquely select a single checkbox and set its checked property to true.<\/p>\n\n\n\n<p>If your jQuery selector returns multiple items, then you will need to use an index to clearly identify the specific checkbox to check. Here&#8217;s an example to check the checkbox with id=&#8217;banana&#8217;.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$('.fruits')[1].checked=true<\/pre>\n\n\n\n<p>In the above code, the &#8216;.fruits&#8217; selector returns all checkboxes with class=&#8217;fruits&#8217;. They are indexed 0, 1, &#8230; with the first checkbox having index=0. We want to check the second checkbox, with index=1. So we mention it in square brackets as [1] immediately after the jQuery selector.<\/p>\n\n\n\n<p>In both the above cases, we check only a single checkbox. If you want, you can also check multiple checkboxes at one go. Just use a selector that returns multiple elements, as shown above, and set their checked property as true.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$('.fruits').checked=true<\/pre>\n\n\n\n<p>The above code both the checkboxes, with class=&#8217;fruits&#8217;, and also sets the checked property of each checkbox to true. This is useful if you have a large number of checkboxes and you want to check all of them at one go.<\/p>\n\n\n\n<p>Another way to check multiple check boxes at one go, is to loop through each checkbox and individually set their checked property to true.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$('.fruits').each(function(){<br>  $(this).checked=true;<br>});<\/pre>\n\n\n\n<p>In the above case, you can individually control whether to set a checkbox or not, in each iteration, instead of setting all returned checkboxes. This is very useful if you have a large number of checkboxes that you want to check but not all of them.<\/p>\n\n\n\n<p>You can also check if a checkbox is checked or not using this property.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">if($('#apple').checked==true){<br>   alert('apple checkbox is checked');<br>}else{<br>   alert('apple checkbox is not checked');<br>}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Using_Prop_Method\"><\/span>2. Using Prop Method<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>jQuery also provides <a href=\"https:\/\/api.jquery.com\/prop\/\" target=\"_blank\" rel=\"noreferrer noopener\">prop()<\/a> function that allows you to set any property of one or more DOM elements. So you can use this function to set the checked property of your checkbox. Here is its syntax.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$('element_selector').prop('checked',true);<\/pre>\n\n\n\n<p>Let us say you have the following two checkboxes.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;form action=\"\/test.php\"&gt;<br>  &lt;input type=\"checkbox\" id=\"volvo\" name=\"volvo\" value=\"volvo\" class=\"cars\"&gt;<br>  &lt;label for=\"volvo\"&gt; Volvo&lt;\/label&gt;&lt;br&gt;<br>  &lt;input type=\"checkbox\" id=\"ford\" name=\"ford\" value=\"ford\" class=\"cars\"&gt;<br>  &lt;label for=\"ford\"&gt; Ford&lt;\/label&gt;&lt;br&gt;<br>&lt;\/form&gt;<\/pre>\n\n\n\n<p>If you want to set the checkbox with id=&#8217;volvo&#8217; you can do so with the following code.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$('#volvo').prop('checked',true);<\/pre>\n\n\n\n<p>If the element selector you use returns multiple items, then you will need to use an index to set the right checkbox. Here is an example where we use the class name as selector, which returns multiple items. So we use index=1 to set checkbox with id=&#8217;ford&#8217;. The first returned item has index 0, the next item has index 1, and so on.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$('.cars')[1].prop('checked',true);<\/pre>\n\n\n\n<p>You can also set multiple checkbox at one go. You just need to call prop() function on it directly as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$('.cars').prop('checked',true);<\/pre>\n\n\n\n<p>In the above code, our jQuery selector returns all items with class=&#8217;cars&#8217; and calls prop() function on each of them to set them.<\/p>\n\n\n\n<p>If you want to control the individual items that are set using the prop() function, then you can loop through them and call prop() function on each item, or only those items that you want.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$('.cars').each(function(){<br>   $(this).prop('checked',true);<br>});<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Using_Attr_Method\"><\/span>3. Using Attr Method<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Similarly, you can also use attr() function, which gets\/sets the attributes of one or more DOM items. Here is the syntax to set a checkbox.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$('element_selector').attr('checked',true);<\/pre>\n\n\n\n<p>Let us say you have the following two checkboxes.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;form action=\"\/test.php\"><br>  &lt;input type=\"checkbox\" id=\"apple\" name=\"apple\" value=\"apple\" class=\"phone\"><br>  &lt;label for=\"apple\"> Apple&lt;\/label>&lt;br><br>  &lt;input type=\"checkbox\" id=\"samsung\" name=\"samsung\" value=\"samsung\" class=\"phone\"><br>  &lt;label for=\"samsung\"> Samsung&lt;\/label>&lt;br><br>&lt;\/form><\/pre>\n\n\n\n<p>Here is an example to set checkbox with id=&#8217;apple&#8217;.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$('#apple').attr('checked',true);<\/pre>\n\n\n\n<p>If the jQuery selector returns multiple items, then you can use an index to pick the appropriate element. Here is an example where our selector class=&#8217;phone&#8217; returns multiple items and we use index=0 to select phone with id=&#8217;apple&#8217;.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$('.phone')[0].attr('checked',true);<\/pre>\n\n\n\n<p>In the above code, the jQuery selector returns all items with class=&#8217;phone&#8217; with index=0 for the first item, index=1 for second item and so on.<\/p>\n\n\n\n<p>You can also set multiple checkboxes at one go as shown below. It returns all items with class=&#8217;phone&#8217; and calls attr() function on them.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$('.phone').attr('checked',true);<\/pre>\n\n\n\n<p>If you want to selectively set multiple checkboxes, then you may want to run a loop through them and call attr() function on only required items. Here is an example to loop through all checkboxes and check only the one where id=&#8217;apple&#8217;.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$('.phone').each(function(){<br>  if($(this).attr('name')=='apple'){<br>       $(this).attr('checked',true);<br>     }<br>});<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this article, we have learnt several easy ways to set checked for checkbox in jQuery. The key is to use the right selector, and then you can use any of the above methods. They offer similar performance. We have learnt how to set a single checkbox, as well as multiple checkboxes in one statement. We have also learnt how to loop through the checkboxes if there are multiple of them and selectively check them, as per our requirement. You can call these functions and attributes from within another jQuery function or in an event handler such as button click.<\/p>\n\n\n\n<p>Also read:<\/p>\n\n\n\n<p><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-include-javascript-file-in-another-javascript-file\/\">How to Include JavaScript File in Another JS File<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-clone-object-in-javascript\/\">How to Clone JavaScript Object<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-detect-browser-in-javascript\/\">How to Detect Web Browser in JavaScript<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Often web developers need to set checkbox on their web page. Here is how to set checked for checkbox in jQuery.<\/p>\n","protected":false},"author":1,"featured_media":5199,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[295],"tags":[323],"class_list":["post-5170","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-set-checked"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Set Checked For Checkbox in jQuery - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Often web developers need to set checkbox on their web page. Here is how to set checked for checkbox in jQuery.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Set Checked For Checkbox in jQuery - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Often web developers need to set checkbox on their web page. Here is how to set checked for checkbox in jQuery.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2024-10-21T05:43:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-21T07:18:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2024\/10\/set-checkbox-jquery.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"288\" \/>\n\t<meta property=\"og:image:height\" content=\"192\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Set Checked For Checkbox in jQuery\",\"datePublished\":\"2024-10-21T05:43:38+00:00\",\"dateModified\":\"2024-10-21T07:18:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/\"},\"wordCount\":934,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2024\/10\/set-checkbox-jquery.jpg?fit=288%2C192&ssl=1\",\"keywords\":[\"set checked\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/\",\"url\":\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/\",\"name\":\"How to Set Checked For Checkbox in jQuery - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2024\/10\/set-checkbox-jquery.jpg?fit=288%2C192&ssl=1\",\"datePublished\":\"2024-10-21T05:43:38+00:00\",\"dateModified\":\"2024-10-21T07:18:50+00:00\",\"author\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Often web developers need to set checkbox on their web page. Here is how to set checked for checkbox in jQuery.\",\"breadcrumb\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2024\/10\/set-checkbox-jquery.jpg?fit=288%2C192&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2024\/10\/set-checkbox-jquery.jpg?fit=288%2C192&ssl=1\",\"width\":288,\"height\":192,\"caption\":\"set checkbox in jquery\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/ubiq.co\/tech-blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Set Checked For Checkbox in jQuery\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#website\",\"url\":\"https:\/\/ubiq.co\/tech-blog\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/\"],\"url\":\"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Set Checked For Checkbox in jQuery - Ubiq BI","description":"Often web developers need to set checkbox on their web page. Here is how to set checked for checkbox in jQuery.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/","og_locale":"en_US","og_type":"article","og_title":"How to Set Checked For Checkbox in jQuery - Ubiq BI","og_description":"Often web developers need to set checkbox on their web page. Here is how to set checked for checkbox in jQuery.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2024-10-21T05:43:38+00:00","article_modified_time":"2024-10-21T07:18:50+00:00","og_image":[{"width":288,"height":192,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2024\/10\/set-checkbox-jquery.jpg","type":"image\/jpeg"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Set Checked For Checkbox in jQuery","datePublished":"2024-10-21T05:43:38+00:00","dateModified":"2024-10-21T07:18:50+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/"},"wordCount":934,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2024\/10\/set-checkbox-jquery.jpg?fit=288%2C192&ssl=1","keywords":["set checked"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/","name":"How to Set Checked For Checkbox in jQuery - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2024\/10\/set-checkbox-jquery.jpg?fit=288%2C192&ssl=1","datePublished":"2024-10-21T05:43:38+00:00","dateModified":"2024-10-21T07:18:50+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Often web developers need to set checkbox on their web page. Here is how to set checked for checkbox in jQuery.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2024\/10\/set-checkbox-jquery.jpg?fit=288%2C192&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2024\/10\/set-checkbox-jquery.jpg?fit=288%2C192&ssl=1","width":288,"height":192,"caption":"set checkbox in jquery"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-set-checked-for-checkbox-in-jquery\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Set Checked For Checkbox in jQuery"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2024\/10\/set-checkbox-jquery.jpg?fit=288%2C192&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-1lo","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/5170","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=5170"}],"version-history":[{"count":32,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/5170\/revisions"}],"predecessor-version":[{"id":5205,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/5170\/revisions\/5205"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/5199"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=5170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=5170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=5170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}