How can I get this to fade, delay, fade out then a different text fade in?

I've got a form with a field that I want to set up in a way where when the user clicks on it, the text of the label changes to a reminder for spouses to include a special character with their Employee ID and then, after a second, the label returns to its original text.

I'm trying this and it's not working:

<!DOCTYPE html>
<script src=""></script>
        $("#usrEEID_text").fadeOut( 500 );
        $("#usrEEID_text").delay( 500 ).text("Wuddup").fadeIn(500);
        $("#usrEEID_text").fadeOut( 500 );
        $("#usrEEID_text").text.("Nice to meet you!");


<input id="usrEEID">

<span id="usrEEID_text">Nice to meet you!</span>
<p>Click in the input field to get focus.</p>


Open in new window

All that's happening is the text changes to "Wuddup," but then doesn't return to "Nice to meet you!" What am I missing?
Bruce GustPHP DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zephyr_hex (Megan)DeveloperCommented:
You have an error here:

$("#usrEEID_text").text.("Nice to meet you!");

Open in new window

should be

$("#usrEEID_text").text("Nice to meet you!");

Open in new window

Don't forget that JavaScript does not wait around for each line to execute.  So you have overlapping events going on that are causing "Wuddup" to not show long enough for a user to see it.  You need to use a promise that waits until the fade out or fade in is done.

        $.when($("#usrEEID_text").fadeOut( 500 )).done(function() {
        	$.when($("#usrEEID_text").delay( 500 ).text("Wuddup").fadeIn(500)).done(function() {
          	$("#usrEEID_text").fadeOut( 500 ).text("Nice to meet you!");;

Open in new window

You might also want to extend the time that "Wuddup" displays so that it doesn't disappear so quickly.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bruce GustPHP DeveloperAuthor Commented:
Thank you!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.