askurat1
asked on
FadeIn and FadeOut with jQuery
I am having some trouble fading in and out my Submit button. The animation works as I want but with a minor issue.
When I enter in the form info, on my contact page, and hit Submit, the Submit button fades out and the success message fades in. This is correct except the fades on the Submit button doesn't seem to finish fading before display is set to none. It animates close to the end and then disappears before it finishes. This makes the animation look jerky.
I want the animation to be smooth all the way to the end.
Here is my site: www.skurat.com
Submit an email form and you will see what I am talking about.
Any help would be great.
Thanks,
Tony
When I enter in the form info, on my contact page, and hit Submit, the Submit button fades out and the success message fades in. This is correct except the fades on the Submit button doesn't seem to finish fading before display is set to none. It animates close to the end and then disappears before it finishes. This makes the animation look jerky.
I want the animation to be smooth all the way to the end.
Here is my site: www.skurat.com
Submit an email form and you will see what I am talking about.
Any help would be great.
Thanks,
Tony
ASKER
Here is the code:
I have already tried what you said and it doesn't seem to work.
This code can be found in custom.js.
var getName = $('#name').val(),
message = '<h5>Thanks, <b>' + getName + '</b>!</h5><h5>Your message has been sent.</h5>'
$('#submit, .sending').fadeOut(1600);
$('.mess').delay(4000).html(message).fadeIn('fast', function () {
$('#form').clearForm();
$(this).delay(5000).fadeOut('slow', function() {
$('#submit').fadeIn('slow');
});
});
I have already tried what you said and it doesn't seem to work.
This code can be found in custom.js.
Should the success be fading in as the submit fades out or waiting til the submit button is completely faded out?
ASKER
It doesn't really matter. I just want the button to fade correctly.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Not sure how this is different from what I have.
ASKER
Updated:
Still does the same thing.
$('#submit, .sending').fadeOut('slow', function (){
$('.mess').delay(1000).html(message).fadeIn('fast', function () {
$('#form').clearForm();
$(this).delay(5000).fadeOut('slow', function() {
$('#submit').fadeIn('slow');
});
});
});
Still does the same thing.
I don't have time right now to rewrite your code but you need to encapsulate the order of things so they run after each other.
So in your ajax call set the sending to show, on successful call back hide the submit/sending and show the success message or an error message
So in your ajax call set the sending to show, on successful call back hide the submit/sending and show the success message or an error message
ASKER
I'm still not understanding. To simplify things I have removed sending from showing.
I'm not sure what I'm doing wrong.
Thanks for the help.
$('#submit').fadeOut('slow', function (){
$('.mess').delay(1000).html(message).fadeIn('fast', function () {
$('#form').clearForm();
$(this).delay(5000).fadeOut('slow', function() {
$('#submit').fadeIn('slow');
});
});
});
I'm not sure what I'm doing wrong.
Thanks for the help.
Does this work for you
http://jsfiddle.net/v7JB8/26/
http://jsfiddle.net/v7JB8/26/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I found the solution.
I suspect you probably just need to cover it with a function
$('submitid').fadeOut('slo
// add code to fade in success
});