我有以下功能,它会弹出一个可以在其中购买的鱼的菜单
.dialog({
title: "Fish Store",
resizable: true,
draggable: true,
modal: true,
buttons: {
"Beard Fish($30)": function() {
if (cash >= 30)
{
fish1 =1;
fish1Swim1();
cash -= 30;
setNav();
$( this ).dialog( "close" );
}
else
{
notEnoughCash();
}
},
"Clown Fish($50)": function() {
if (cash >= 50)
{
fish2 = 1;
fish2Swim1();
cash -= 50;
setNav();
$( this ).dialog( "close" );
}
else
{
notEnoughCash();
}
},
"Neon Fish($75)": function() {
if (cash >= 75)
{
fish3 = 1;
fish3Swim1();
cash -= 75;
setNav();
$( this ).dialog( "close" );
}
else
{
notEnoughCash();
}
}
}
});
我想编辑该函数,以便可以根据 if 变量(fish1、fish2 和 fish3)打开和关闭按钮。
所以我尝试进行以下更改...
buttons: {
if(fish1=0)
{
"Beard Fish($30)": function() {
if (cash >= 30)
{
fish1 =1;
fish1Swim1();
cash -= 30;
setNav();
$( this ).dialog( "close" );
}
else
{
notEnoughCash();
}
},
}
但我的文本编辑说语法无效,我怎样才能使它工作?