jquery - how do i make a div slide left 100px everytime i click a link

纵饮孤独 提交于 2020-01-02 20:09:50

问题


What i have so far is this

$(function(){
    $("#click").click(function(){
        $("#slide").animate({marginLeft:'100px'},'slow');                  
    });            
});

Heres a link to a demo

Which works only once, but if i try to click the link again, Nothing happens

how do I make it so it works more like a slideshow? so everytime I click, it slides left


回答1:


Something like this. You use += expression:

$(function(){
    $("#click").click(function(){
        $("#slide").animate({left:'+=100px'},'slow');                  
    });            
});


来源:https://stackoverflow.com/questions/7440112/jquery-how-do-i-make-a-div-slide-left-100px-everytime-i-click-a-link

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!