何らかの理由で、ページがリフレッシュされると正しく実行されません。それ以外はうまく動作します。 id.backgroundはbodyタグにあります。jquery background resize
var theWindow = $(window),
$bg = $("#background"),
aspectRatio = $bg.width()/$bg.height();
function resizeBg() {
if ((theWindow.width()/theWindow.height()) < aspectRatio) {
$bg.removeClass()
.addClass('bgheight');
} else {
$bg.removeClass()
.addClass('bgwidth');
}
}
theWindow.resize(function() {
resizeBg();
}).trigger("resize");
文書準備完了イベントでサイズ変更をトリガーしていますか?例えば、 '$(document).ready(function(){theWindow.trigger( 'resize');}); ' –
ええ、probがそれを追加しているはずです。 –