私はブラウザのウィンドウ幅の結果を取得しようとしていて、数学と条件の結果を変数に入れようとしていました。これはコードです
var MyWidth = 1900;
var MyHeight = 900;
var height = $(window).height();
var width = $(window).width();
var AutoW = function () {
if ( (MyWidth / width).toFixed(2) > 0.95 )
return 1;
if ( (MyWidth / width).toFixed(2) < 1.05 )
return 1;
else return (MyWidth / width).toFixed(2);
};
alert(AutoW);
問題は、変数に割り当てられた関数の正しい構文または構造がわからないことです
これをコーディングする正しい方法は何ですか?