我在IE9
模式下IE7
收到以下错误。使用小型计数脚本:
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
中使用此功能,但此错误会破坏脚本。
答案 0 :(得分:8)
删除onComplete
之后的逗号逗号。
答案 1 :(得分: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
答案 2 :(得分: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
};