JQuery issue with IE8

As a step towards learning jQuery, I am trying to create a Sudoku in which I have generated numbers in divs from 1 to 89 (leaving 10 divisible numbers). My code works well in Google Chrome, but IE8 generates div id in different ways.

Please check this fiddle

I highly doubt the error must be due to incompatibility of some jQuery methods. The problem may lie in the following steps:

var lastNumId = parseInt(_idGen.toString().substr(-1), 10);
var secondLastNumId = parseInt(_idGen.toString().charAt(_idGen.length - 2), 10);

      

In the lines above, I used different methods to do the same thing, because if I do it, it works in Chrome.

+3


source to share


1 answer


Using a negative index is substr

not supported by IE before version 9.

Just use the modulo operator to get the last digit of a number. This also works in IE8:



var lastNumId = _idGen % 10;

      

+4


source







All Articles