Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: Object [object Object] has no method 'apply'

I am receiving this Uncaught TypeError on a new website I am creating, but I can't work out what is causing the error.

I have recreated the issue at the link below, if you take a look at your browsers JS console you'll see the error occurring, but nothing else happens.

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

Code:

$('.newsitem').hover(
$(this).children('.text').animate({ height: '34px' }), 
$(this).children('.text').animate({ height: '0px'  }));​
like image 804
David Pooley Avatar asked Jun 14 '12 12:06

David Pooley


Video Answer


3 Answers

Be sure to wrap those in asynchronous callbacks:

$('.newsitem').hover(
    function() {
        $(this).children('.title').animate({height:'34px'});
    }, function() {
        $(this).children('.title').animate({height:'0px'});
    }
);
​
like image 155
Aram Kocharyan Avatar answered Nov 15 '22 04:11

Aram Kocharyan


You need:

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

as per the documentation.

like image 33
Evan Mulawski Avatar answered Nov 15 '22 05:11

Evan Mulawski


You're missing the function...

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

To:

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

And the ​$(this).children('.text'), is not selecting anything.

like image 25
gdoron is supporting Monica Avatar answered Nov 15 '22 04:11

gdoron is supporting Monica