未捕获的类型错误: 对象 [对象对象] 没有方法'apply'



我在正在创建的新网站上收到此未捕获的类型错误,但我无法找出导致错误的原因。

我已经在下面的链接中重新创建了这个问题,如果您查看浏览器 JS 控制台,您将看到错误发生,但没有其他发生。

http://jsfiddle.net/EbR6D/2/

法典:

$('.newsitem').hover(
$(this).children('.text').animate({ height: '34px' }), 
$(this).children('.text').animate({ height: '0px'  }));​

请务必将它们包装在异步回调中:

$('.newsitem').hover(
    function() {
        $(this).children('.title').animate({height:'34px'});
    }, function() {
        $(this).children('.title').animate({height:'0px'});
    }
);
​

你需要:

.hover(function(){ ... });

根据文档。

你错过了function...

$('.newsitem').hover(
    $(this).children('.text').animate({height:'34px'}),
    $(this).children('.text').animate({height:'0px'})
);

自:

$('.newsitem').hover(function() {
    $(this).children('.text').animate({
        height: '34px'
    });
}, function() {
    $(this).children('.text').animate({
        height: '0px'
    });
});​
​

$(this).children('.text'),没有选择任何东西。

使用幻灯片动画来处理 .text 类的高。

$('.newsitem').hover(function() {
    $(this).children('.text').slideToggle();
});​
​

相关内容

最新更新