0

IE9IE7模式下我收到以下错误。使用一个小的计数脚本:

SCRIPT1028:预期的标识符、字符串或数字

代码

$.fn.countTo.defaults = {
    from: 0,  // the number the element should start at
    to: 100,  // the number the element should end at
    speed: 1000,  // how long it should take to count between the target numbers
    refreshInterval: 100,  // how often the element should be updated
    decimals: 2,  // the number of decimal places to show
    onUpdate: null,  // callback method for every time the element is updated,
    onComplete: null,  // callback method for when the element finishes updating
};

第 185 行是最后一个大括号和分号

我们需要它来工作,IE7但这个错误正在破坏脚本。

4

3 回答 3

8

去掉后面的逗号onComplete

于 2012-05-29T21:06:35.250 回答
5
$.fn.countTo.defaults = {
   from: 0,  // the number the element should start at
   to: 100,  // the number the element should end at
   speed: 1000,  // how long it should take to count between the target numbers
   refreshInterval: 100,  // how often the element should be updated
   decimals: 2,  // the number of decimal places to show
   onUpdate: null,  // callback method for every time the element is updated,
   onComplete: null  // callback method for when the element finishes updating
};

后面去掉逗号onComplete: null

于 2012-05-29T21:06:50.503 回答
2

问题在于默认值的最终值的最后一个逗号。IE对此有问题。让它像这样,你应该很好:

$.fn.countTo.defaults = {
    from: 0,  // the number the element should start at
    to: 100,  // the number the element should end at
    speed: 1000,  // how long it should take to count between the target numbers
    refreshInterval: 100,  // how often the element should be updated
    decimals: 2,  // the number of decimal places to show
    onUpdate: null,  // callback method for every time the element is updated,
    onComplete: null  // callback method for when the element finishes updating
};
于 2012-05-29T21:07:41.050 回答