0

I followed a tutorial and got a fadeIn effect working in HTML with Javascript and no CSS

This sounds really dumb but I have no Idea how can I make the second step to fade to a third step

<script type="text/javascript">
    $(document).ready(function() {
        $('#weiter').click(function() {

            $('#age option:selected').each(function() {
                if ($(this).val() == "no") alert('Why.');
                if ($(this).val() == "under") alert('Hallo');
                if ($(this).val() == "ok") {
                    $('#step1').fadeOut('fast', function() {
                        $('#step2').fadeIn('fast');
                    });
                }
            });
        });
    });
</script>

        <div id="step1">
            Hello
            <p align="center">
                <input id="weiter" class="btn" type="button" value="Next&raquo;">
            </p>
        </div>

        <div id="step2">
            Welcome
            <p align="center">
                <input id="weiter" class="btn" type="button" value="Next&raquo;">
            </p>
        </div>

        <div id="step3">
            Bye
        </div>
ekclone
  • 1,030
  • 2
  • 17
  • 39

2 Answers2

1

Technically, you could do:

$('#step1').fadeOut('fast', function() {
    $('#step2').fadeIn('fast', function(){
        $('#step3').fadeIn('fast');
    });
});

Also, there are many plugins for doing this kind of sequential animations. Full discosure; one of those are mine. I created it a while back when I had the same problem: https://github.com/fillswitch/Jquery-Sequential-Animations

Fillip Peyton
  • 3,637
  • 2
  • 32
  • 60
0
 $('#step1').fadeOut('fast', function() {
       $('#step2').fadeIn('fast', function() {

                 $('#step2').fadeOut('fast', function() {
                                $('#step3').fadeIn('fast', function() {
                                });
                });

        });
});

Try this

Smit kalwal
  • 422
  • 2
  • 13