0

so basically i would like to collect data from a numeric column on my site, but from taking that data i would like to import it to a div. the div will be a money counter that will continue adding on data collected from the table itself, i DO NOT want the counter to reset after every new data is entered in the table. i would just like the data to keep adding up to a unlimited number.

example of the codes i have collected so far:

<script>

var 
table = document.getElementById('tableID'),

cells = table.getElementsByTagName('td');

for 

(var i=0,len=cells.length; i<len; i++){

cells[i].onclick = function(){

console.log(this.innerHTML);


console.log(parseInt(this.innerHTML),10);

}
} </script>
4

1 回答 1

0

try this jQuery :

$('.myClassAbleToAddOnCounter').bind('click', function(){
  var currentCount = parseInt($('#myCounterTotal').html());
  var countToAdd = parseInt($(this).html());

  $('#myCounterTotal').html( currentCount + countToAdd );
});
于 2013-08-02T10:08:21.923 回答