0

I'd like to make a loop that assigns a variable to each of the 0-9 digit pads on a calculator. Here is what I would like to work:

var numpad = [];
for (var i = 0; i < 10; ++i) {
    numpad[i] = $('[data-num="i"]');
}

Resulting in:

numPad[1] = $('[data-num="1"]');
numPad[2] = $('[data-num="2"]');
numPad[3] = $('[data-num="3"]');
etc...

I tried several variations of string escapes but nothing gave me the element.

dooblr
  • 458
  • 1
  • 5
  • 18

0 Answers0