2

I have 2 button elements. On the click of the first button, the second button appears and first one disappears. @Fiddle

$(document).ready(function () {
    $("#startClock").click(function () {
        $("#startClock").fadeOut().delay(120000).fadeIn();
        $("#submitamt").fadeIn().delay(120000).fadeOut();         
    });
});
<button class="rightbtn" type="button" id="startClock">Start</button>
<button class="rightbtn" type="button" id="submitamt" style="display:none;">Submit</button>

Everything is fine but when the second button replaces the first one it slides from right to left. I want that the second button should replace the first one directly over it, without sliding/taking any space/without affecting CSS

Can anyone tell how to do so?

1
  • Despite this is a css matter (should be solved with css, not mandatory though), you can easily trick that out adding an additional delay, like this: jsfiddle.net/L5kto35b/4 .. Or you can just concatenate the callbacks, but it might be harder to read. Commented Jun 15, 2015 at 8:53

2 Answers 2

3

Try this, Might help

you need to use callbacks

$(document).ready(function () {
    $("#startClock").click(function () {
        $("#startClock").fadeOut(function(){
          $("#submitamt").fadeIn().delay(120000).fadeOut(function(){
                   $("#startClock").delay(120000).fadeIn();
          });
        })

    });
});

or simply

 $(document).ready(function () {
        $("#startClock").click(function () {
            $("#startClock").fadeOut(function(){
              $("#submitamt").fadeIn().delay(120000).fadeOut(function(){
                       $("#startClock").fadeIn();
              });
            })

        });
    });

in this case only once it will delay for 120000 milisecs.

Updated Fiddle

Sign up to request clarification or add additional context in comments.

Comments

0

Replace in your jQuery code

$(document).ready(function () {
    $("#startClock").click(function () {
        $("#startClock").fadeOut().delay(120000,function(){
           $("#submitamt").fadeIn().delay(120000); 
    });
}); });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.