EnexoOnoma
EnexoOnoma

Reputation: 8836

How to add a fade-in effect in jQuery text

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

Answers (3)

xecute
xecute

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

sg3s
sg3s

Reputation: 9567

This might just do the trick.

$('#results').css('display', 'none').html(data).fadeIn('slow');

Upvotes: 0

aziz punjani
aziz punjani

Reputation: 25776

You gotta hide the div first.

$('#results').hide().html(data).fadeIn('slow');

Upvotes: 3

Related Questions