Get height of image inside a hidden div

前端 未结 9 578
自闭症患者
自闭症患者 2021-01-02 18:50

i want to to get the height/width of an image inside a hidden div-containter, but .height() and .width() both returns 0 (like expected).

         


        
9条回答
  •  说谎
    说谎 (楼主)
    2021-01-02 19:02

    Make the div temporarily visible in order to compute the height or hide the div off screen instead of using display: None. I have used the first approach, and found it to be fast enough that you will never see the element.

提交回复
热议问题