jQuery:如何表示 div 的宽度 +多几个像素?
我想将 div 动画设置到左侧,即 div 的宽度 + 100px。
我有这样的代码:
$('#mydiv').animate({left:-$('#mydiv').outerWidth()},1000);
这会在 1000 毫秒内向左移动到 #mydiv 宽度的距离。
我怎样才能再添加 100 个像素呢?
将不胜感激您的专业建议!
I want to animate a div to the left, to the width of the div + 100px.
I have this code:
$('#mydiv').animate({left:-$('#mydiv').outerWidth()},1000);
This animates it in 1000 milliseconds to the left, to the distance of the width of #mydiv.
How can I add 100 more pixels to that?
Would be grateful for your expertly advice!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为什么不试试这个呢:
Why not try this instead:
$('#mydiv').animate({left:-($('#mydiv').outerWidth() + 100)},1000);
$('#mydiv').animate({left:-($('#mydiv').outerWidth() + 100)},1000);
尝试:
不确定为什么在左值之前需要减法运算符?
Try:
Not sure why you need the subtraction operator before the left value?