This code hides #title, sets the text, then fades it in.
$('#title').fadeOut(0).text(data.name).fadeIn();
Is there a better way to do the fadeOut(0) part?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you just want to hide the element instantly, then fade it in with new text, do this:
If instead you want it to animate, your code doesn’t wait for anything to happen: it starts to fade in, then sets text instantly, and then fades out (without waiting for anything to finish).
Use callbacks, which are anonymous functions which get called after the parent function has executed completely:
I really wish jQuery’s functions could be chained that easily…
Good luck!