简体   繁体   English

jQuery动画到偏移量/位置

[英]jQuery animate to offset/position

I'm using jQuery animate to change the position of an element: 我正在使用jQuery动画来更改元素的位置:

$('#item').animate({'top' : '-50'}, 0);

I don't need the animation, I just want to set the position. 我不需要动画,我只想设置位置。 I tried both offset and position , but neither seemed to work right. 我尝试了offsetposition ,但似乎都无法正常工作。

How should update this to not use animate? 如何将其更新为不使用动画?

Thank you! 谢谢!

您可以尝试:

$('#item').css({'top' : '-50'});

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

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