だから私は 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 の両方で発生します。ここで何が欠けていますか?