offset.top value different in document ready and c

2019-07-29 05:43发布

问题:

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();