Mr_Green
Mr_Green

Reputation: 41832

jquery issue with IE8

As a step to learn jQuery, I am trying to create Sudoku, in which I generated numbers in div blocks from 1 to 89 (leaving 10 divisible numbers). My code works good in Google chrome but IE8 generates the div id's differently.

Please check this fiddle

I highly doubt the error must be because of incompatibility of some methods of jQuery. The problem could be in the following steps:

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

In the above lines to do the same, I used different techniques because if I do so then it is working in Chrome.

Upvotes: 3

Views: 285

Answers (1)

Guffa
Guffa

Reputation: 700152

Using a negative index in substr is not supported by IE until version 9.

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

var lastNumId = _idGen % 10;

Upvotes: 4

Related Questions