奇怪的IE7怪癖

abs*_*ntx 0 javascript jquery

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
};
Run Code Online (Sandbox Code Playgroud)

第185行是最后一个花括号和半冒号

我们需要这个工作,IE7但这个错误打破了脚本.

Dav*_*ton 8

之后删除尾随的逗号onComplete.


ahr*_*ren 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
};
Run Code Online (Sandbox Code Playgroud)

之后删除逗号 onComplete: null