0

基本上我有一个 div 在单击右箭头或左箭头时水平移动。使用以下 jQuery:

$(".arrow_right").click(function(){
$(".movingdiv").animate({marginLeft: '+=-225px'}, 500);
});

$(".arrowcontainer_left").click(function(){
$(".movingdiv").animate({marginLeft: '+=225px'}, 500);
});

为确保移动的 div 不会离开屏幕,我希望左箭头的 css 更改为:

  visibility:hidden; 

当移动 div 的 margin-left 等于 0px 时。当移动 div 的 margin-left 等于 675px (或单击三下)时,右箭头也是如此

任何帮助将非常感激。

4

1 回答 1

1

这样做。

$(".arrowcontainer_left").click(function(){
    $(".movingdiv").animate({marginLeft: '+=225px'}, 500,function() { 
        if($(".movingdiv").css("margin-left") == "675px")
        {   // your stuff to hide
        }
    });
});
于 2013-07-18T18:07:13.657 回答