5

作成中の新しい Web サイトでこの Uncaught TypeError を受け取りましたが、エラーの原因がわかりません。

以下のリンクで問題を再現しました。ブラウザの JS コンソールを見ると、エラーが発生していることがわかりますが、他には何も起こりません。

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

コード:

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

4 に答える 4

5

それらを非同期コールバックで必ずラップしてください。

$('.newsitem').hover(
    function() {
        $(this).children('.title').animate({height:'34px'});
    }, function() {
        $(this).children('.title').animate({height:'0px'});
    }
);
​
于 2012-06-14T12:08:08.820 に答える
3

必要なもの:

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

ドキュメントによると。

于 2012-06-14T12:05:47.747 に答える
2

あなたは行方不明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'
    });
});​
​

そして、<code> $(this).children('。text')は何も選択していません。

于 2012-06-14T12:06:34.607 に答える
0

スライド アニメーションを使用して、.text クラスの高さを処理します。

$('.newsitem').hover(function() {
    $(this).children('.text').slideToggle();
});​
​
于 2012-06-14T12:24:03.213 に答える