简体   繁体   中英

moving back and forth div

Im trying to create some moving div, actually remake one, so that div would move endlessly back and forth, here is the script:

function animate(px) {
    $('.download').animate({
        'marginLeft' : "-10px"
    });
}

Thanks for help! ;)

Don't forget to add position: relative to the #download element before doing this:

var func = function() {
    $(".download").animate({"left": "-40px"}, 1000, function() { 
        $(this).animate({"left": "40px"}, 1000) 
    })

    setTimeout(func, 2000);
}

//Or remove setTimeout and use the following line instead:
//func(); setInterval(func, 2000);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM