简体   繁体   English

动画jQuery onclick绝对位置移动

[英]Animate jquery onclick absolute position move

I'm trying to animate this 'sliderish' thing that I just made. 我正在尝试为刚制作的“滑行”动画。 And since i'm an infant when it comes to jquery i'm having trouble. 而且由于我是jquery的婴儿,所以遇到了麻烦。

I thought this would work but it isn't. 我以为这可以用,但是没有用。

$('ul').animate({.css('left', -600)}, "slow");

but obviously that isn't working 但显然那是行不通的

$('#slide-left').click(function(){
    $('ul').css('left', 0);

     return false;
});
$('#slide-right').click(function(){
     $('ul').css('left', -600);

     return false;
});
$('#back-right').click(function(){
    $('ul').css('left', -300);

     return false;
});
$('#back-left').click(function(){
    $('ul').css('left', -300);

     return false;
});

heres a fiddle http://jsfiddle.net/NePyd/3/ 这是一个小提琴http://jsfiddle.net/NePyd/3/

You have the wrong syntax for animate, it's .animate( properties [, duration ] [, easing ] [, complete ] ) : 您为动画设置的语法错误,它是.animate( properties [, duration ] [, easing ] [, complete ] )

$('ul').animate({left: -600}, 600);

Check out the docs for a more comprehensive understanding of .animate() 查看文档,以更全面地了解.animate()

updated fiddle 更新的小提琴

$('ul').animate({'left':0}, "slow");

见小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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