所以我试图读取通过 jquery 创建的 img 元素的高度和宽度。
这是我要执行的代码
$(document).ready(function() 
{
    $.ajax({
            url: 'res/script/getImage.php', 
            type: 'POST',
            data: {
                param  : 'Load'
            },
            success: function(result)
            {
                ImageArray = JSON.parse(result);
               for(i=0; i<ImageArray.length; i++)
                {
                        //Read the Image element and update to gallery
                        document.getElementById("gallery").innerHTML += ImageElement;
                        ImageArrayComplete[ImageCounter] = ImageArray[i].image;
                        UserArrayComplete[ImageCounter]  = ImageArray[i].user;
                }
             //Create Canvas
            $('#gallery img').each(function() {
                console.log(this);
                console.log('Width=' + this.width+ 'Height='+this.height);
                createCanvas(this);
            });
            }
        });
});
的输出console.log(this);是预期的图像路径。
但是console.log('Width=' + this.width+ 'Height='+this.height);在初始页面加载期间,宽度和高度的输出均为 0。
刷新页面后,该值将重置为 200 的实际宽度。
在 Firefox 和 chrome 中都没有抛出任何其他错误。我在这里想念什么?