offset.top value different in document ready and console.log() why?

ⅰ亾dé卋堺 提交于 2019-12-22 14:02:26

问题


in my case, my about page is parallax moving well every section when i'm click on about's sub menu (submenu for same page #link). but in my site home page has the same submenu if somebody click on the submenu first goto about page then the exact position. I make it almost done. but offset().top not giving me the exact value. so I stuck.

I console to see offset.top value when document ready..

help me to understand why this happen???

thanks in advance. sorry for poor english

my site is here http://doitte.com/delatest/


回答1:


this is because on document ready some of the content may have not got their height. This could be due to resources such as images, font-faces, delayed css/js loading etc.

Instead of using $(document).ready(); go for $(window).load();



来源:https://stackoverflow.com/questions/26648411/offset-top-value-different-in-document-ready-and-console-log-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!