David Pooley
David Pooley

Reputation: 81

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

Upvotes: 5

Views: 19177

Answers (4)

kongaraju
kongaraju

Reputation: 9596

use slide animation to handle hight of the .text class.

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

Upvotes: 0

Aram Kocharyan
Aram Kocharyan

Reputation: 20431

Be sure to wrap those in asynchronous callbacks:

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

Upvotes: 5

gdoron
gdoron

Reputation: 150263

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.

Upvotes: 2

Evan Mulawski
Evan Mulawski

Reputation: 55334

You need:

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

as per the documentation.

Upvotes: 3

Related Questions