I use a function that onclick runs to read an xml catalog and opens a thumbnail for each catalog entry.
I want the script to open each thumb suquentially. And logically I feel it should do that as the show command is at the end of the for loop. But the function runs and all the thumbnails show at the same time. How can I change this? Why does this happen?
function showproductthumbnails() {
for (i=0;i<xmlcatalog.length;i++){
$(catalogitem+i).show("fold", {size:3}, 300);
}
}
Note that the code above is just the abstract with the meat taken out, but the problem remains.
How can I change this?
You can add a small delay [docs]:
$(catalogitem+i).delay(i*100).show("fold", {size:3}, 300);
Why does this happen?
The loop is amazingly fast and calling show like this is not blocking. Animation functions are asynchronous.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With