Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does jQuery throw the error `fadeOut is not a function'?

Tags:

jquery

I am using jQuery and put this code in my javascript:

function HideMe(itemID) {     var myDiv = 'item_' + itemID;     $(myDiv).fadeOut("slow"); } 

But its giving me this error: fadeOut is not a function.

like image 782
Marc V Avatar asked Jun 01 '09 11:06

Marc V


People also ask

What is fadeOut in jQuery?

jQuery Effect fadeOut() Method The fadeOut() method gradually changes the opacity, for selected elements, from visible to hidden (fading effect). Note: Hidden elements will not be displayed at all (no longer affects the layout of the page). Tip: This method is often used together with the fadeIn() method.

What is the syntax of jQuery fadeOut () method?

The jQuery fadeOut() method is used to fade out a visible element. Syntax: $(selector). fadeOut(speed,callback);

What is fadeIn and fadeOut in jQuery?

The fadeIn method displays the element by fading it to opaque. The fadeOut method hides the element by fading it to transparent. Note – jQuery does the fading by changing the opacity of the element.

What is the difference between fadeOut and hide in jQuery?

fadeOut() the place will be removed at once. . show(duration) and . hide(duration) animate the size of element (also the opacity) to 100% and 0% and the place of elements is also animated in that duration.


2 Answers

This will happen if you're using the "slim" version of jQuery. Only the "full" version of jQuery includes animation effects.

Try grabbing the "full" version of jQuery from the jQuery downloads page and including that in your page (or including a full version of jQuery from a CDN from your page).

like image 69
Jon Schneider Avatar answered Sep 19 '22 14:09

Jon Schneider


Do you have another javascript library on that page? It seems you have the hide function, and the $ defined (prototype, for example, also has an hide function).
If that is the case, try:

jQuery("#item_0").fadeOut("slow"); 
like image 45
Kobi Avatar answered Sep 17 '22 14:09

Kobi