使用javascript禁用HTML中的按钮

使用javascript禁用HTML中的按钮,javascript,html,button,Javascript,Html,Button,在我的游戏中,玩家有一个平衡点,当他们点击按钮时,它会下降5000,当他们达到0时,他们会以20000开始,我希望出现一个警报(我有这个功能)并禁用该按钮-我无法让它工作,有人能解释一下吗?所有的功能都工作得很好顺便说一句,我只是想在“减法”功能中添加禁用按钮-谢谢 这是我正在使用的代码 <script type="text/javascript"> function subtract() { var Balance = document.getElementById("Balan

在我的游戏中,玩家有一个平衡点,当他们点击按钮时,它会下降5000,当他们达到0时,他们会以20000开始,我希望出现一个警报(我有这个功能)并禁用该按钮-我无法让它工作,有人能解释一下吗?所有的功能都工作得很好顺便说一句,我只是想在“减法”功能中添加禁用按钮-谢谢

这是我正在使用的代码

<script type="text/javascript">
function subtract() {

var Balance = document.getElementById("Balance");
var Fee = parseInt(Balance.value) - 5000;
Balance.value = Fee;

if(Fee <= 0){
alert("To Continue Playing - Purchase More Coins at - LINK");
}
}
</script>


<button class="randombutton"  id="aaa" style="float:left;" onclick= "
 randomImg1(); 
 randomImg2(); 
 randomImg3(); 
 randomImg4(); 
 randomImg5(); 
 randomImg6(); 
 randomImg7(); 
 randomImg8();
 subtract();
 foo(this);"/>OPEN PACK</button>

函数减法(){
var余额=document.getElementById(“余额”);
风险值费用=parseInt(余额价值)-5000;
余额.价值=费用;

如果要使用javascript禁用表单元素,请将属性设置为
true

function subtract() {

    var Balance = document.getElementById("Balance");
    var Fee = parseInt(Balance.value) - 5000;
    Balance.value = Fee;

    if(Fee <= 0){
        // Get the element and then set the disabled property to true.
        document.getElementById('aaa').disabled = true;

        alert("To Continue Playing - Purchase More Coins at - LINK");
    }
}
函数减法(){
var余额=document.getElementById(“余额”);
风险值费用=parseInt(余额价值)-5000;
余额.价值=费用;

如果要使用javascript禁用表单元素,请将属性设置为
true

function subtract() {

    var Balance = document.getElementById("Balance");
    var Fee = parseInt(Balance.value) - 5000;
    Balance.value = Fee;

    if(Fee <= 0){
        // Get the element and then set the disabled property to true.
        document.getElementById('aaa').disabled = true;

        alert("To Continue Playing - Purchase More Coins at - LINK");
    }
}
函数减法(){
var余额=document.getElementById(“余额”);
风险值费用=parseInt(余额价值)-5000;
余额.价值=费用;

如果要使用javascript禁用表单元素,请将属性设置为
true

function subtract() {

    var Balance = document.getElementById("Balance");
    var Fee = parseInt(Balance.value) - 5000;
    Balance.value = Fee;

    if(Fee <= 0){
        // Get the element and then set the disabled property to true.
        document.getElementById('aaa').disabled = true;

        alert("To Continue Playing - Purchase More Coins at - LINK");
    }
}
函数减法(){
var余额=document.getElementById(“余额”);
风险值费用=parseInt(余额价值)-5000;
余额.价值=费用;

如果要使用javascript禁用表单元素,请将属性设置为
true

function subtract() {

    var Balance = document.getElementById("Balance");
    var Fee = parseInt(Balance.value) - 5000;
    Balance.value = Fee;

    if(Fee <= 0){
        // Get the element and then set the disabled property to true.
        document.getElementById('aaa').disabled = true;

        alert("To Continue Playing - Purchase More Coins at - LINK");
    }
}
函数减法(){
var余额=document.getElementById(“余额”);
风险值费用=parseInt(余额价值)-5000;
余额.价值=费用;

如果我可以的话,我会竖起你的大拇指:)谢谢!如果我可以的话,我会竖起你的大拇指:)谢谢!如果我可以的话,我会竖起你的大拇指:)谢谢!如果我可以的话,我会竖起你的大拇指:)