Is there any way to read out the “naturalWidth” of an image with jquery?

前端 未结 8 2145
时光说笑
时光说笑 2020-12-05 10:59

I tried with something like this:

var Height = $(this).naturalHeight;

But it doesn\'t work. Is there any way to do that

greez

8条回答
  •  北海茫月
    2020-12-05 11:07

    Would just try

    var width = $("img", this).css('width', 'auto').width();
    var height= $("img", this).css('height', 'auto').height();
    

    Is basically the calculation for naturalWidth and naturalHeight anyway

提交回复
热议问题