2012-06-14 13 views
5

Recibo este Unbeught TypeError en un nuevo sitio web que estoy creando, pero no puedo determinar qué está causando el error.Uncaught TypeError: Object [objeto Object] no tiene ningún método 'apply'

He vuelto a crear el problema en el siguiente enlace, si echas un vistazo a la consola JS de tu navegador verás que se está produciendo el error, pero no sucede nada más.

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

Código:

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

¿Dónde está '.text' en el HTML? – gdoron

+0

lo siento, debería haber leído .título –

Respuesta

5

Asegúrese de envolver los de devoluciones de llamada asincrónicas:

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

que necesita:

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

según el documentation.

+1

jajaja No puedo creer que haya mirado ese código por más de un minuto y no haya notado que no está pasando una función: P – Esailija

+0

Gracias, sabía que sería obvio. pero simplemente no pude verlo. –

2

Te estás perdiendo el function ...

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

Para: nada

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

Y el $(this).children('.text'), no está seleccionando.

0

uso animación de diapositivas para manejar altura de la clase .text.

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