3

I got something that I want to do and want to see what you guys think and how can it be implemented.

I got a form in a page and the form will submit to itself to perform some process (run functions) in a class.

Upon clicking the submit button, I want to animate the button text to “SUBMIT .” -> “SUBMIT ..” -> “SUBMIT …” -> “SUBMIT ….” -> “SUBMIT ….” and then back again. Sort of “animate” the button text.

Once the whole process is done, the button text will goes back to be “SUBMIT” text again.

Please note that I am not looking for image button solution, meaning that I do not want to implement gif animated button image.

Anyone done this before or know how this can be done? I have google but seems nothing of this kind to be found.

2 Answers 2

2

Set up a timer with javascript, that will run until the process is done, be sure to have a flag for it.

And since you are using jQuery, you can simply $("#button-id").val(nextStep); where nextStep is the next animation string. Example:

function putAnimation () {
    var b = [".", "..", "..." ];
    var i = 0;

    var a = setInterval(function () {
        $("#button-id").val("SUBMIT " + b[i++]);

        if (stopped) {
            $("#button-id").val("SUBMIT");
            clearInterval(a);
        }
    }, 500);
}
Sign up to request clarification or add additional context in comments.

Comments

1

For the animation itself:

$('#submit').click(function() {
  $(this).val("Submit    ").delay(200).val("Submit .").delay(200).val("Submit ..").delay(200).val("Submit ...").delay(200).val("Submit").delay(200);
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.