title: JQuery find value of checkbox and check the checkbox based on value
body: <p>I have an array of checkboxes. I need to check the boxes based on the text value for the checkbox.  For examples if I have three checkboxes with the text &quot;Checkbox 01.&quot;, &quot;Checkbox 02.&quot; and &quot;Checkbox 03.&quot; and I have a checkbox called &quot;Select All&quot;.  I want to iterate through the array of checkboxes and only check items that contain the word &quot;02.&quot; or &quot;03.&quot;</p>
  <p>I'm not proficient in JQuery, I inherited this, but I took a stab at the code and here is what I tried:</p>
  <pre><code>$(&quot;.rightColumn .SelectAllGroups&quot;).on(&quot;click&quot;, function () {
      if (this.checked) {
          $(&quot;.GroupSelection input:checkbox&quot;).each(function (i) {
              //alert(&quot;Index of item&quot; + i);
              if (this(i).val.contains(&quot;01.&quot;) || this(i).val.contains(&quot;02.&quot;) || this(i).val.contains(&quot;03.&quot;) ||
                  this(i).val.contains(&quot;04.&quot;) || this(i).val.contains(&quot;05.&quot;) || this(i).val.contains(&quot;06.&quot;) || this(i).val.contains(&quot;07 .&quot;) ||
                  this(i).val.contains(&quot;08.&quot;) || this(i).val.contains(&quot;09.&quot;) || this(i).val.contains(&quot;10.&quot;) || this(i).val.contains(&quot;11.&quot;)) {
                  this(i).checked = i;
              }
          });
      } else {
          $(&quot;.GroupSelection input:checkbox&quot;).each(function () {
              this.checked = false;
          });
      }
  });
  </code></pre>
  <p>Just an FYI, the value &quot;07 .&quot; does have a space whereas the others don't.  When I run this I get the error &quot;This is not a function&quot;.  The textboxes are created via code.  Here is the result of one textbox</p>
  <pre><code>&lt;input name=&quot;ctl00$ctl00$ctl00$mainBody$mainContent$main$newEpisodeForm$NewSnapshot$GroupSelection$groupTypeList$ctl01$groupList$ctl00$groupCheck&quot; type=&quot;checkbox&quot; id=&quot;mainBody_mainContent_main_newEpisodeForm_NewSnapshot_GroupSelection_groupTypeList_groupList_1_groupCheck_0&quot; isoptionalgroup=&quot;true&quot; value=&quot;ae37b870-e525-4cce-9315-1e8e4e253483&quot;&gt;
  &lt;span id=&quot;mainBody_mainContent_main_newEpisodeForm_NewSnapshot_GroupSelection_groupTypeList_groupList_1_groupLabel_0&quot;&gt;01. First Test&lt;/span&gt;
  </code></pre>
  <p>Thanks.</p>