, inline, , , . , onload, . onload? . , jQuery ready onload, . , load window load. jQuery ready .
, :
$(window).bind('load', function() {
var img = $("#theimage");
log("Width: " + img.width());
log("Height: " + img.height());
});
... ( log - , ), :
$(document).ready(function() {
$("#theimage").bind('load', function() {
var img = $(this);
log("Width: " + img.width());
log("Height: " + img.height());
});
});
... :
$(document).ready(function() {
var img = $("#theimage");
log("Width: " + img.width());
log("Height: " + img.height());
});
... .
. : " load ( window), , , load . :
$(document).ready(function() {
var img, imgElement;
img = $("#theimage");
imgElement = img[0];
if (imgElement && imgElement.complete) {
loadHandler.call(imgElement);
}
else {
img.bind('load', loadHandler);
}
function loadHandler() {
var img = $(this);
log("Width: " + img.width());
log("Height: " + img.height());
img.unbind('load', loadHandler);
}
});
loadHandler , ready.