-1

I have 4 pictures which I want to change every 3 seconds, but fade it out/in.

I change the pictures successfully but when I add the fadeOut I get the error action.js:14 Uncaught TypeError: $(...).fadeOut is not a function

$(document).ready(function(){

    count = 1;
    setInterval(function () {
       
        count++;

        $('#mainimg').fadeOut(200, function() { //THIS CAUSES THE ERROR
            $('#mainimg').attr('src','img/phone' + count + '.png');
        });

        if(count == 4){
            count = 1;
        }

    }, 3000);

})

This is the entire JS code I have, there is nothing more.

IkePr
  • 900
  • 4
  • 18
  • 44

2 Answers2

0

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");
0

I found out the problem. jQuery was slim version, not minifed. That's why it was throwing the error. The jQuery library didn't have fade. Fixed it by just adding the CDN for the minifed version.

IkePr
  • 900
  • 4
  • 18
  • 44