コンソールにエラーがあります:
TypeError: $("<img/>").attr("src", e.attr("src")) is undefine
$('<img/>').attr('src', e.attr('src')).load(function(){
関数のコード全体は次のとおりです。
function resizeOriginalImg(element, original)
{
var e = jQuery(element);
var newWidth, newHeight, imageWidth, imageHeight, realWidth, realHeight;
$('<img/>').attr('src', e.attr('src')).load(function(){
realWidth = this.width;
realHeight = this.height;
});
if(original)
{
imageWidth = realWidth;
imageHeight = realHeight;
}
else
{
imageWidth = e.width();
imageHeight = e.height();
}
if(imageWidth > jQuery(window).width() || imageHeight > jQuery(window).height())
{
if(imageWidth >= imageHeight)
{
newWidth = jQuery(window).width();
newHeight = (newWidth/imageWidth)*imageHeight;
}
else
{
newHeight = jQuery(window).height();
newWidth = (newHeight/imageHeight)*imageWidth;
}
}
e.css({'width' : newWidth, 'height' : newHeight});
};
と:
resizeOriginalImg('.current-slide .myimage', true);
何が問題なのかわかりません。すべて問題ないように見えますが、機能しません。多分
$('<img/>').attr('src', e.attr('src')).load(function()
悪い場所にあり、エラーが発生しますか?
事前にご協力いただきありがとうございます。