Reputation: 8836
How to add a fade-in effect when the data is returned to the #results
div?
$('#results').html(data);
I tried
$('#results').html(data).fadeIn('slow');
but it doesn't seem to work
My code
submitHandler: function(form) {
// do other stuff for a valid form
$.post('mailme.php', $("#myform").serialize(), function(data) {
$('#results').html(data).fadeIn('slow');
});
}
Upvotes: 0
Views: 405
Reputation: 455
you have to hide element firstly when you are working with "fadeIn".
here is a example, I believe you will understand after trying and editing that:
<img style="display: none;" id="google" src="http://www.google.com.tr/images/srpr/logo3w.png" alt="" />
<script>
$(document).ready(function() {
$('#google').fadeIn(1200,function(){});
});
</script>
Upvotes: 0
Reputation: 9567
This might just do the trick.
$('#results').css('display', 'none').html(data).fadeIn('slow');
Upvotes: 0
Reputation: 25776
You gotta hide the div first.
$('#results').hide().html(data).fadeIn('slow');
Upvotes: 3