I have the table below. I also have this array who’s values correspond to the data-id attributes of the rows [52,24,12]. One and only one row will exist in the table for each array value. I would like to increment the count column for each row which exists in the array. For instance, 12 would change to 13, 32 would change to 33, and 6 would change to 7. A jQuery solution is preferred, however, a native JavaScript solution would suffice. Thank you
<table>
<thead>
<tr><td>count</td></tr>
</thead>
<tbody>
<tr data-id="24"><td>32</td></tr>
<tr data-id="52"><td>12</td></tr>
<tr data-id="42"><td>4</td></tr>
<tr data-id="84"><td>2</td></tr>
<tr data-id="12"><td>6</td></tr>
</tbody>
</table>
Try this (I’m using lib from underscorejs.org)
or w/o underscore:
http://jsfiddle.net/ACJ9r/