I'm having an issue with my jquery script... should an easy task, but having some strange behaviours that I can't figure out.
When I click on a link, I want my content to disappear, then the new content to reappear. All content is stored in tags.
Here's what I'm using:
$("#events_link").click(function() {
$("#content").children(".content").fadeOut(fadetime, function() {
$("#events").fadeIn(fadetime);
});
return false
});
However, the fadeIn is not waiting until the content has faded out.
My full page is here (all code/script on one page):
http://dl.dropbox.com/u/4217965/HorrorInTheHammer/index.html
Any thoughts?
This will run for each of the
.content_box
elements...and the hidden ones will finish their animation immediately, so you want is this:The important change is the
:visible
selector, so only the visible one is faded out...and triggers the callback to show the next one.windows.setTimeout is not always useful because sometimes the process might take more time than the timeout you have set. So it's better to use following code to run fadeIn only after fadeOut is done.
The current version of your page doesn't appear to be working at all because you have something like
instead of
Fix that and it will be easier to troubleshoot...
EDIT (now that above fix is done):
It does seem like the fadeOut function is not working quite as documented, at least in Firefox 3.5, in regard to callbacks. I think what you probably want can be accomplished by using a little plain-old javascript:
I think that will more likely accomplish what you want by trying to ensure that the old content is gone and no longer actually taking up space before fading in the new content. Let us all know if it works for you.