开发者

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

开发者 https://www.devze.com 2023-04-05 10:57 出处:网络
What i have so far is this $(function(){ $(\"#click\").click(function(){ $(\"#slide\").animate(开发者_开发知识库{marginLeft:\'100px\'},\'slow\');

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


Something like this. You use += expression:

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

精彩评论

暂无评论...
验证码 换一张
取 消