Image native width in jquery

后端 未结 4 1204
广开言路
广开言路 2021-01-21 02:58

With jQuery, i change the src of an image on click

$(\"#thumb li img\").click(function() {
var newlinkimage = $(this).attr(\"src\");

newlinkimage = newlinkimage         


        
4条回答
  •  猫巷女王i
    2021-01-21 03:57

    this code always return Zero '0'

        var newimage = new Image();
        newimage.src = 'retouche-hr' + newlinkimage.substring(14,17) + '-a.jpg'; 
        var width = newimage.naturalWidth;
        var height = newimage.naturalHeight;
        alert (width);
    

    WHY ???

提交回复
热议问题