2012-06-14 15 views
5

Sto ricevendo questo errore Uncaught Type su un nuovo sito Web che sto creando, ma non riesco a capire quale causa l'errore.Unchaught TypeError: Object [oggetto Object] non ha alcun metodo 'apply'

Ho ricreato il problema al collegamento seguente, se dai un'occhiata alla tua console JS del browser vedrai che si sta verificando l'errore, ma non succede nient'altro.

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

Codice:

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

Dove si trova '.text' nell'HTML? – gdoron

+0

scusate, che avrebbe dovuto leggere .title –

risposta

5

ricordarsi di quelli di callback asincroni:

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

devi:

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

come da documentation.

+1

lol Non posso credere di aver fissato quel codice per più di un minuto e non ho notato che non sta passando una funzione: P – Esailija

+0

Grazie, sapeva che sarebbe stato ovvio. ma non potevo vederlo. –

2

Stai perdendo il function ...

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

A: niente

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

E il $(this).children('.text'), non è la selezione.

0

uso animazione diapositive per gestire altezza della classe .text.

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