私はフェード効果を実行しようとしています。これは、divをフェードアウトして、別のdivに置き換えます。そのために、最後にクリックされたdivの数を設定するlastDiv変数を作成しました。
しかし、if jsがエラーがあると言った場合、設定しようとすると。私は正しい構文を使用していると確信しています。(私は初心者です)
ありがとう
var lastDiv = 1;
$("#item1").click(function () {
if(lastDiv == 2) { $("#div2").fadeOut(0500, function() { $("#div1").fadeIn(500, function () {lastDiv = 1;}); }); }); }
else if (lastDiv == 3) { $("#div3").fadeOut(0500, function() { $("#div1").fadeIn(500, function () {lastDiv = 1;}); }); }); }
$("#item2").click(function () {
if(lastDiv == 1){ $("#div1").fadeOut(0500, function() { $("#div2").fadeIn(0500, function () {lastDiv = 2;}) }); }); }
else if(lastDiv == 3){ $("#div3").fadeOut(0500, function() { $("#div2").fadeIn(0500, function () {lastDiv = 2;}) }); }); }
$("#item3").click(function () {
if(lastDiv == 1) { $("#div1").fadeOut(0500, function() { $("#div3").fadeIn(0500, function () { lastDiv = 3 }) }); }
else if(lastDiv == 2) { $("#div2").fadeOut(0500, function() { $("#div3").fadeIn(0500, function () { lastDiv = 3 }) }); } });
</script>