开发者

interval timed dual fadeouts in jquery

开发者 https://www.devze.com 2023-03-28 03:28 出处:网络
WOW am i having 开发者_如何学JAVAproblems. Im trying to create a cycling testimonials area where the testimonial and client fade in and out at the same time. Im using setInterval() and having a bunch

WOW am i having 开发者_如何学JAVAproblems. Im trying to create a cycling testimonials area where the testimonial and client fade in and out at the same time. Im using setInterval() and having a bunch of issues. Im also thinking I am completely misunderstanding queue().

It's not following my 'counter++ variable'. The elements are repeating. And the timing gets mismatched real fast. Can someone pls tell me what im doing wrong?

If you check out this jsfiddle code you'll see exactly what im trying to do.

http://jsfiddle.net/qbB6s/2/

thanks so much!


I think you may be making it more complicated than it needs to be :). I wrote up a quick jsFiddle for reference, but I'd say that you could make a couple of changes to the way you've got your markup structured that would make the transitions much cleaner:

  • Keep the testimonials and clients in the markup rather than an array. Only use an array if you're going to be doing something like pulling the comments via ajax.

  • Don't worry too much about the queue method or keeping track of counters. Instead, use a classname on the elements to track which ones are currently being displayed (my jsFiddle shows this).

If you take a look at the sample code, you can also easily apply effects. Rather than using toggle(), you could use something like fadeToggle().

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号