![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, real simple problem, but I am struggling to find a solution. I have an array: var arr = [ "one", "two", "three", "four", "five" ]; and I want to fade the values in and out, moving on to the next one. I've tried 'jQuery.each()', for loops, and so on, but I either get the last one of the list fading in and out over and over, or it doesn't work at all. What I tried first was: $(document).ready(function(){ var arr = [ "one", "two", "three", "four", "five" ]; jQuery.each (arr, function() { $('#box_content').text(this).fadeIn().fadeOut(); }); }); Now, I'm up to this: $(document).ready(function(){ var arr = [ "one", "two", "three", "four", "five" ]; for (i=0; i<5; i++) { $("#box_content").fadeOut('slow').fadeIn('slow', function () { $ (this).text(arr[i]); }); } }); I think what's happening on a lot of attempts is that the loop is going on through, and not waiting for the function. So, I was hoping that putting it in the callback would solve that. I've done a lot of ajax with jquery, but evidently, I need to brush up on my animation stuff. Thanks for your help. -Greg |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
$(this).fadeOu(duration, function() { Typo Sent from my iPhone On 8 Nov 2009, at 07:27, Michel Belleville <michel.belleville (AT) gmail (DOT) com wrote: $(this).fadeOu(duration, function() { |
#5
| |||
| |||
|
|
Typo indeed ^^° Though the principle is sound. Michel Belleville 2009/11/8 Sam Doyle <sammeh.... (AT) gmail (DOT) com $(this).fadeOu(duration, function() { Typo Sent from my iPhone On 8 Nov 2009, at 07:27, Michel Belleville <michel.bellevi... (AT) gmail (DOT) com wrote: $(this).fadeOu(duration, function() { |
#6
| |||
| |||
|
|
I'm not sure I follow what the principle is? On Nov 8, 1:16 pm, Michel Belleville <michel.bellevi... (AT) gmail (DOT) com wrote: Typo indeed ^^° Though the principle is sound. Michel Belleville 2009/11/8 Sam Doyle <sammeh.... (AT) gmail (DOT) com $(this).fadeOu(duration, function() { Typo Sent from my iPhone On 8 Nov 2009, at 07:27, Michel Belleville michel.bellevi... (AT) gmail (DOT) com wrote: $(this).fadeOu(duration, function() { |
#7
| |||
| |||
|
|
To use callbacks that are triggered actually when the animation finishes instead of calling the animations all at once and seeing only the very last because they all start approximately at the same time. Michel Belleville 2009/11/9 gthorne <gtho... (AT) gmail (DOT) com I'm not sure I follow what the principle is? On Nov 8, 1:16 pm, Michel Belleville <michel.bellevi... (AT) gmail (DOT) com wrote: Typo indeed ^^° Though the principle is sound. Michel Belleville 2009/11/8 Sam Doyle <sammeh.... (AT) gmail (DOT) com $(this).fadeOu(duration, function() { Typo Sent from my iPhone On 8 Nov 2009, at 07:27, Michel Belleville michel.bellevi... (AT) gmail (DOT) com wrote: $(this).fadeOu(duration, function() { |
#8
| |||
| |||
|
|
Is that close to what I was doing on the second example, where I was calling $().text in the callback portion of fadeIn()? On Nov 9, 12:38 am, Michel Belleville <michel.bellevi... (AT) gmail (DOT) com wrote: To use callbacks that are triggered actually when the animation finishes instead of calling the animations all at once and seeing only the very last because they all start approximately at the same time. Michel Belleville 2009/11/9 gthorne <gtho... (AT) gmail (DOT) com I'm not sure I follow what the principle is? On Nov 8, 1:16 pm, Michel Belleville <michel.bellevi... (AT) gmail (DOT) com wrote: Typo indeed ^^° Though the principle is sound. Michel Belleville 2009/11/8 Sam Doyle <sammeh.... (AT) gmail (DOT) com $(this).fadeOu(duration, function() { Typo Sent from my iPhone On 8 Nov 2009, at 07:27, Michel Belleville michel.bellevi... (AT) gmail (DOT) com wrote: $(this).fadeOu(duration, function() { |
![]() |
| Thread Tools | |
| Display Modes | |
| |