title: How to sum value of checked changed checkbox jquery?
body: <p>I have a table, each checkbox contains a value,  and I want to sum value of the checkbox.</p>
  
  <p><strong>Example:</strong></p>
  
  <p>Candy and Water is checked : count = 2 , Candy, food and water is checked : count = 5 , checkbox is unchecked : count = 0 . 
  I think i must two event , event of each checkbox (.checkbox1) and event of checkbox (.check_all).</p>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code>      var count = 0;
              $(".checkbox1").change(function() {
                  var table_abc = document.getElementsByClassName("checkbox1");
                  for (var i = 0; table_abc[i]; ++i) {
                      if (table_abc[i].checked) {
                          count += table_abc[i].value;
                      }
                  }
             });
  
  alert(count);
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;table id="div_table"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;&lt;input type="checkbox" class="check_all" id="chk_all" /&gt;&lt;/th&gt;
              &lt;th&gt;Check All&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="checkbox" class="checkbox1" id="candy" value="2" /&gt;&lt;/td&gt;
              &lt;td&gt;Candy&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="checkbox" class="checkbox1" id="food" value="3" /&gt;&lt;/td&gt;
              &lt;td&gt;Food&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="checkbox" class="checkbox1" id="water" value="0" /&gt;&lt;/td&gt;
              &lt;td&gt;Water&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>But it seems not working. Can you tell me how to wrong?</p>