2012-06-14 11 views
5

作成中の新しいWebサイトでこのUncaught TypeErrorを受け取りましたが、エラーの原因を解消できません。Uncaught TypeError:オブジェクト[オブジェクトオブジェクト]にメソッド '適用'がありません

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

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

コード:

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

HTMLで '.text'はどこにありますか? – gdoron

+0

申し訳ありませんが、それは.title –

答えて

5

は、非同期コールバックでそれらをラップしてください:の.textクラスの絶頂を処理するため

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

あなたが必要です:documentationあたりとして

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

+1

LOLを読んでいるはずです。私はそのコードを1分以上見つめて、彼が関数を渡していないことに気がつきませんでした:P – Esailija

+0

ありがとう、分かりました。私はそれを見ることができませんでした。 –

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' 
    }); 
});​ 
​ 

そして$(this).children('.text')、何も選択されていません。

0

使用にスライドアニメーション。

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