Jquery.height() returns different results using F5 or CTRL+F5

后端 未结 5 2114
心在旅途
心在旅途 2021-01-22 10:40

So I am trying to find the height of my images then add a top margin this enables me to impose a a vertical center.

I\'m running this code, and on an F5 refresh<

5条回答
  •  佛祖请我去吃肉
    2021-01-22 10:49

    There is a difference between onload and onready.

    ready will wait until the actual DOM-tree is done, while onload will wait until ALL of the content displayed on the page is finnished loading. So an explanation would be that when clearing the cache and refreshing, the dom tree finishes much faster than the images, hence giving the wrong heigh.

    Try using the onload-event instead and see if you get a different result.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题