Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using jQuery animate a div from top to bottom?

Tags:

html

jquery

css

i am using this code and it's working correct moving from top to bottom but i want to move continuously not single time. Thanks!!

    $(document).ready(function(){
     var bodyHeight = $('body').height();
     var footerOffsetTop = $('#moving').offset().top;
     var topToBottom = bodyHeight -footerOffsetTop;
     $('#moving').css({top:'auto',bottom:topToBottom});
     $("#moving").delay(100).animate({
     top: '100px',
     }, 3000);  
    })
like image 601
uzair_hashmi89 Avatar asked Nov 28 '25 02:11

uzair_hashmi89


1 Answers

$(document).ready(function() {
    setInterval(function(){
        var bodyHeight = $('body').height();
        var footerOffsetTop = $('#moving').offset().top;
        var topToBottom = bodyHeight - footerOffsetTop;
        $('#moving').css({
            top : 'auto',
            bottom : topToBottom
        });
        $("#moving").delay(100).animate({
            top : '100px',
        }, 3000);       
    }, 3200);
})
like image 153
Atif Avatar answered Nov 30 '25 15:11

Atif



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!