Animating marginLeft with jQuery

后端 未结 3 1217
予麋鹿
予麋鹿 2021-01-03 22:46

I can\'t figure out to animate marginLeft with jQuery. I need it to subtract 938px every time a user clicks on a link, which was working fine when I was using .css()

相关标签:
3条回答
  • 2021-01-03 22:55

    There's a syntax error in your code, as you are passing parameters in an object to animate() you should use : not , to delimit each attribute. Try this:

    $("#full-wrapper #full").animate({
        marginLeft: '-=938px'
    }, 500);
    

    Example fiddle

    0 讨论(0)
  • 2021-01-03 23:00

    Replace comman(,) by colon(:).

    $("#full-wrapper #full").animate({
        marginLeft: "-=938px"
    }, 500);
    
    0 讨论(0)
  • 2021-01-03 23:02
    $("#full-wrapper #full").animate({
        marginLeft: '-=938px'
    }, 500);
    
    0 讨论(0)
提交回复
热议问题