您好,我正面临这个奇怪的 JQuery 问题。我的JS:
$("#flip-counter").centerH();
function centerH() {
var marginL = ( $(window).width() - $(this).width() ) / 2;
$(this).css("marginLeft",marginL+"px");
alert(marginL);
}
收到此错误:
Uncaught TypeError: Object [object Object] has no method 'centerH'
(anonymous function)
k jquery.js:2
l.fireWith jquery.js:2
p.extend.ready jquery.js:2
D jquery.js:2
jquery.js:2 为空。
我会理解是否没有任何代码可以工作,但现在一切正常,除此之外我无法添加任何其他功能。我只是不断收到同样的错误。所有文件都正确包含,当我删除这段 JS 代码时,我的代码就像一个魅力。
有什么建议么?