0

See title. It seems to load fine and transitions nicely into one picture, but then refuses to work after that.

When I used Chrome to check and see what's wrong, it told me it didn't recognize the slideSwitch function, even though things worked fine when I tested it out locally.

Anyway, I hope the masters here at stackoverflow will be able to help my feeble minded self.

Thanks in advance.

jQuery code:

$(function slideSwitch() {
     var $active = $('#slideshow img.active');

     if ($active.length == 0) $active = $('#slideshow img:last');

     var $next = $active.next().length ? $active.next() : $('#slideshow img:first');

     $active.addClass('last-active');

     $next.css({
         opacity: 0.0
     }).addClass('active').animate({
         opacity: 1.0
     }, 2000, function () {
         $active.removeClass('active last-active');
     });
 });

 $(function () {
     setInterval("slideSwitch()", 5000);
 });

And here's it's accompanying CSS:

#slideshow {
    height:327px;
    border:thick #000;
    list-style:none;
    margin:0px auto;
    width:600px;
    overflow: hidden;
    position:relative;
}

#slideshow img {
     border: solid #000000 10px;
     display:block;
     position:absolute;
     z-index: 8;
}

#slideshow img.active {
    z-index:10;
}

#slideshow img.last-active {
    z-index:9;
}
Milap
  • 6,915
  • 8
  • 26
  • 46
choglad
  • 23
  • 2
  • 11
  • hey can you pop-in some html as well, might be able to help you out, cheers! If you can't give HTML see this example here - **working** http://jsfiddle.net/skelly/D6BGj/ (and cheer up brother everyone are good including you so no one is feeble mind :) – Tats_innit Mar 30 '12 at 07:18

2 Answers2

0

Try:

setInterval( function(){
   slideSwitch();
}, 5000 );
matpol
  • 3,042
  • 1
  • 15
  • 18
0

Because setinterval is an eval.

So do this:

window.setInterval(function() {
    slideSwitch();
}, 5000);

See: http://jsfiddle.net/cxPU6/

Read more here: window.setInterval from inside an object

I get the same problem over and over again :)

Community
  • 1
  • 1
Marco Johannesen
  • 13,084
  • 6
  • 31
  • 36
  • Yeah! Thanks! Worked out perfectly! If there was some way to give you an apple or something via webs, I would definitely do it. – choglad Mar 30 '12 at 18:51