EnRico Lam
EnRico Lam

Reputation: 55

unexpected token error in the code

thr below is my code, i try to make tdsum an array, but some how error shows up and i cannot fix it no matter what i did, can anyone please help me, i have tried to replace ntr with numbers and other characters, but it does not work either, so i suspect that there is something i missed that is not related to the ntr part

var tdsum = [];
function find(element,ntr) {
  alert(element.cells[0].innerHTML);
  var tr_sum = element.parentNode.childElementCount
  var tdsum[ntr] = element.childElementCount;
  alert(ntr);
  alert(tdsum[2])
}
$('#row2').click(); 

Upvotes: 0

Views: 31

Answers (1)

Scott Marcus
Scott Marcus

Reputation: 65806

You don't declare elements in an array. You only need to declare the array itself.

Remove the var on this line:

tdsum[ntr] = element.childElementCount;

Upvotes: 1

Related Questions