{"id":20966,"date":"2022-11-11T14:01:11","date_gmt":"2022-11-11T08:31:11","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/"},"modified":"2022-11-11T14:01:11","modified_gmt":"2022-11-11T08:31:11","slug":"solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/","title":{"rendered":"[Solved] How use Jquery checkbox value and Class attribute set arrays"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-31473112\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"31473112\" data-parentid=\"31472426\" data-score=\"1\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>You can do this as  :<\/p>\n<\/p>\n<div class=\"snippet\" data-lang=\"js\" data-hide=\"false\">\n<div class=\"snippet-code\">\n<pre class=\"snippet-code-js lang-js prettyprint-override\"><code>$(document).ready(function () {\r\n\r\n    $('.checkboxes input[type=\"checkbox\"]').change(function () {\r\n        var A = new Array();\r\n        var B = new Array();\r\n        var C = new Array();\r\n        var param = $(this).attr('class');\r\n        $(\" input[type=\"checkbox\"]:checked\").each(function () {\r\n            if ($(this).hasClass('A')) {\r\n                A.push($(this).attr(\"value\"));\r\n            }\r\n            if ($(this).hasClass('B')) {\r\n                B.push($(this).attr(\"value\"));\r\n            }\r\n            if ($(this).hasClass('C')) {\r\n                C.push($(this).attr(\"value\"));\r\n            }\r\n            });\r\n            \/\/alert(\"value ===&gt; \" + mycheck + \" ===&gt; parameter ===&gt; \"+param);\r\n            alert(\"parameter ===&gt; A ===&gt; value ===&gt;\" + A +\r\n                  \"\\nparameter ===&gt; B ===&gt; value ===&gt;\" +B +\r\n                  \"\\nparameter ===&gt; C ===&gt; value ===&gt;\" +C \r\n                 );\r\n            });\r\n        });<\/code><\/pre>\n<pre class=\"snippet-code-html lang-html prettyprint-override\"><code>&lt;script src=\"https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.11.1\/jquery.min.js\"&gt;&lt;\/script&gt;\r\n&lt;div class=\"checkboxes\"&gt;\r\n    &lt;input type=\"checkbox\" value=\"a1\" class=\"A\"\/&gt; a\r\n    &lt;input type=\"checkbox\" value=\"a2\" class=\"A\"\/&gt; a\r\n    &lt;input type=\"checkbox\" value=\"a3\" class=\"A\"\/&gt; a\r\n    &lt;input type=\"checkbox\" value=\"a4\" class=\"A\"\/&gt; a\r\n    &lt;input type=\"checkbox\" value=\"a5\" class=\"A\"\/&gt; a\r\n    &lt;input type=\"checkbox\" value=\"a6\" class=\"A\"\/&gt; a\r\n&lt;\/div&gt;\r\n&lt;br&gt;\r\n&lt;div class=\"checkboxes\"&gt;\r\n    &lt;input type=\"checkbox\" value=\"b1\" class=\"B\"\/&gt; b\r\n    &lt;input type=\"checkbox\" value=\"b2\" class=\"B\"\/&gt; b\r\n    &lt;input type=\"checkbox\" value=\"b3\" class=\"B\"\/&gt; b\r\n    &lt;input type=\"checkbox\" value=\"b4\" class=\"B\"\/&gt; b\r\n    &lt;input type=\"checkbox\" value=\"b5\" class=\"B\"\/&gt; b\r\n    &lt;input type=\"checkbox\" value=\"b6\" class=\"B\"\/&gt; b\r\n&lt;\/div&gt;\r\n&lt;br&gt;\r\n&lt;div class=\"checkboxes\"&gt;\r\n    &lt;input type=\"checkbox\" value=\"c1\" class=\"C\"\/&gt; c\r\n    &lt;input type=\"checkbox\" value=\"c2\" class=\"C\"\/&gt; c\r\n    &lt;input type=\"checkbox\" value=\"c3\" class=\"C\"\/&gt; c\r\n    &lt;input type=\"checkbox\" value=\"c4\" class=\"C\"\/&gt; c\r\n    &lt;input type=\"checkbox\" value=\"c5\" class=\"C\"\/&gt; c\r\n    &lt;input type=\"checkbox\" value=\"c6\" class=\"C\"\/&gt; c\r\n&lt;\/div&gt;<\/code><\/pre>\n<\/div>\n<\/div><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\"><\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved How use Jquery checkbox value and Class attribute set arrays <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] You can do this as : $(document).ready(function () { $(&#8216;.checkboxes input[type=&#8221;checkbox&#8221;]&#8217;).change(function () { var A = new Array(); var B = new Array(); var C = new Array(); var param = $(this).attr(&#8216;class&#8217;); $(&#8221; input[type=&#8221;checkbox&#8221;]:checked&#8221;).each(function () { if ($(this).hasClass(&#8216;A&#8217;)) { A.push($(this).attr(&#8220;value&#8221;)); } if ($(this).hasClass(&#8216;B&#8217;)) { B.push($(this).attr(&#8220;value&#8221;)); } if ($(this).hasClass(&#8216;C&#8217;)) { C.push($(this).attr(&#8220;value&#8221;)); } }); \/\/alert(&#8220;value ===&gt; &#8230; <a title=\"[Solved] How use Jquery checkbox value and Class attribute set arrays\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/\" aria-label=\"More on [Solved] How use Jquery checkbox value and Class attribute set arrays\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[464,346,333,388],"class_list":["post-20966","post","type-post","status-publish","format-standard","hentry","category-solved","tag-css","tag-html","tag-javascript","tag-jquery"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] How use Jquery checkbox value and Class attribute set arrays - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] How use Jquery checkbox value and Class attribute set arrays - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] You can do this as : $(document).ready(function () { $(&#039;.checkboxes input[type=&quot;checkbox&quot;]&#039;).change(function () { var A = new Array(); var B = new Array(); var C = new Array(); var param = $(this).attr(&#039;class&#039;); $(&quot; input[type=&quot;checkbox&quot;]:checked&quot;).each(function () { if ($(this).hasClass(&#039;A&#039;)) { A.push($(this).attr(&quot;value&quot;)); } if ($(this).hasClass(&#039;B&#039;)) { B.push($(this).attr(&quot;value&quot;)); } if ($(this).hasClass(&#039;C&#039;)) { C.push($(this).attr(&quot;value&quot;)); } }); \/\/alert(&quot;value ===&gt; ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-11T08:31:11+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] How use Jquery checkbox value and Class attribute set arrays\",\"datePublished\":\"2022-11-11T08:31:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/\"},\"wordCount\":29,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"css\",\"html\",\"javascript\",\"jquery\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/\",\"name\":\"[Solved] How use Jquery checkbox value and Class attribute set arrays - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-11-11T08:31:11+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] How use Jquery checkbox value and Class attribute set arrays\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] How use Jquery checkbox value and Class attribute set arrays - JassWeb","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:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] How use Jquery checkbox value and Class attribute set arrays - JassWeb","og_description":"[ad_1] You can do this as : $(document).ready(function () { $('.checkboxes input[type=\"checkbox\"]').change(function () { var A = new Array(); var B = new Array(); var C = new Array(); var param = $(this).attr('class'); $(\" input[type=\"checkbox\"]:checked\").each(function () { if ($(this).hasClass('A')) { A.push($(this).attr(\"value\")); } if ($(this).hasClass('B')) { B.push($(this).attr(\"value\")); } if ($(this).hasClass('C')) { C.push($(this).attr(\"value\")); } }); \/\/alert(\"value ===&gt; ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/","og_site_name":"JassWeb","article_published_time":"2022-11-11T08:31:11+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] How use Jquery checkbox value and Class attribute set arrays","datePublished":"2022-11-11T08:31:11+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/"},"wordCount":29,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["css","html","javascript","jquery"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/","url":"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/","name":"[Solved] How use Jquery checkbox value and Class attribute set arrays - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-11-11T08:31:11+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-how-use-jquery-checkbox-value-and-class-attribute-set-arrays\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] How use Jquery checkbox value and Class attribute set arrays"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/20966","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=20966"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/20966\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=20966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=20966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=20966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}