javascript 未捕获的类型错误:对象 [object Object] 没有方法“应用”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11032659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uncaught TypeError: Object [object Object] has no method 'apply'
提问by David Pooley
I am receiving this Uncaught TypeError on a new website I am creating, but I can't work out what is causing the error.
我在我创建的新网站上收到此 Uncaught TypeError,但我无法弄清楚是什么导致了错误。
I have recreated the issue at the link below, if you take a look at your browsers JS console you'll see the error occurring, but nothing else happens.
我在下面的链接中重新创建了这个问题,如果您查看浏览器的 JS 控制台,您会看到错误发生,但没有其他任何事情发生。
Code:
代码:
$('.newsitem').hover(
$(this).children('.text').animate({ height: '34px' }),
$(this).children('.text').animate({ height: '0px' }));?
采纳答案by Aram Kocharyan
Be sure to wrap those in asynchronous callbacks:
确保将它们包装在异步回调中:
$('.newsitem').hover(
function() {
$(this).children('.title').animate({height:'34px'});
}, function() {
$(this).children('.title').animate({height:'0px'});
}
);
?
回答by Evan Mulawski
回答by gdoron is supporting Monica
You're missing the function
...
你错过了function
...
$('.newsitem').hover(
$(this).children('.text').animate({height:'34px'}),
$(this).children('.text').animate({height:'0px'})
);
To:
到:
$('.newsitem').hover(function() {
$(this).children('.text').animate({
height: '34px'
});
}, function() {
$(this).children('.text').animate({
height: '0px'
});
});?
?
And the ?$(this).children('.text')
, is not selecting anything.
而 ? $(this).children('.text')
, 没有选择任何东西。
回答by Konga Raju
use slide animation to handle hight of the .text class.
使用幻灯片动画处理 .text 类的高度。
$('.newsitem').hover(function() {
$(this).children('.text').slideToggle();
});?
?