Get height of image inside a hidden div

前端 未结 9 624
自闭症患者
自闭症患者 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 18:59

    you have to use find()

    $('body').find('#myimg').width();
    

    or

    $('body').find('#myimg').attr("width");
    

    becouse you have appended it after the DOM was loaded

提交回复
热议问题