简体   繁体   中英

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.

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM