Elsa
Elsa

Reputation: 69

How can I move a div from top to bottom by using jQuery?

I would like to make an effect like : click a button, and the top div will hide, then bottom div will scroll from top to bottom.

I have finished hide the top div, but it's failed to make the bottom div getting down (?

I think maybe it's because my css and js get something wrong (?), but I'm not sure, and I've modified several times. = (

Here's my javascript code:

$(function(){

        $("#btn1").click(function(){
            $(".slot-top").hide();
            $("#slot ul").animate({ top: "0em" },1500);
            return false;
        });

    });

Here's my code: https://jsfiddle.net/b1mj1c1L/

Upvotes: 1

Views: 1414

Answers (1)

Simon Kraus
Simon Kraus

Reputation: 736

You messed up the jQuery Selector. Instead of $("#slot ul").animate({ top: "0em" },1500); use $(".slot").animate({ top: "0em" },1500);. See here: https://jsfiddle.net/b1mj1c1L/1/

Upvotes: 2

Related Questions