Shahil Mohammed
Shahil Mohammed

Reputation: 3868

Text fade in and out jquery

I have an issue. I have two text. On page load when first text fades out i want the second text to fade in same line and the second text should stay. Here is my fiddle http://jsfiddle.net/st6rxwjr/1/

Here is my code :

<div class="text1 animated  zoomIn">Welcome to our site</div>
<div class="animated text2 bounceIn">Company Name</div>

CSS:

body { padding-top:30px;}
.text2 {
    display: none;
}
div {
    font-size:30px;
    font-weight:bold;
    text-transform:uppercase;
    text-align:center;
}

JS :

function fade() {
    $('.text1').fadeIn().delay(2000).fadeOut();
    $('.text2').delay(2000).fadeIn();
}
    fade();

Upvotes: 0

Views: 532

Answers (2)

ketan
ketan

Reputation: 19341

I think you need like: Fiddle.

Change in your Jquery code text2 delay. You given 2000 So text2 will appear before text1 will disappear.

function fade() {
        $('.text1').fadeIn().delay(2000).fadeOut();
        $('.text2').delay(2500).fadeIn();

}
    fade();

Upvotes: 0

Developer107
Developer107

Reputation: 1758

Try using call back function like this:

function fade() {
    $('.text1').fadeIn().delay(2000).fadeOut(1000,function(){
        $('.text2').delay(2000).fadeIn();
    });
}

You can put 0 instead of 1000 if you don't want any slow fade In effect.

Upvotes: 1

Related Questions