简体   繁体   中英

jQuery animate to offset/position

I'm using jQuery animate to change the position of an element:

$('#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.

How should update this to not use animate?

Thank you!

您可以尝试:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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