can't get true height/width of object in chrome

后端 未结 4 1338
囚心锁ツ
囚心锁ツ 2021-02-06 03:20

I have a question, if i set a image height in css and try to get height/width i get different results in different browsers. Is there a way to get the same dimension in all brow

4条回答
  •  滥情空心
    2021-02-06 04:05

    Nick Craver's answer to use $(window).load() is correct, but the images also have a load() method, which allows finer granularity, especially if there are perhaps multiple images to load.

      $(document).ready(function(){ 
        $("#top_img_0").load (function (){
          $("#text").append( "height: " + $("#top_img_0").attr("height")+"
    " ); $("#text").append( "width: " + $("#top_img_0").attr("width")+"
    " ); }); });

提交回复
热议问题