禁用按钮

时间:2016-04-19 05:30:06

标签: javascript jquery ajax button

点击后我需要帮助尝试使我的按钮无效,任何帮助都会感激不尽,如果您需要更多信息,请问我,谢谢!任何帮助将不胜感激。

function addGame() 
{
    var side = $("#side").val();
    var steamid = $("#steamid").val();
    var amount = $("#amount").val();
    var buttonText = document.getElementById('createGameButton').innerHTML;

    if(buttonText=='Are you sure?')
    {
        $.ajax(
        {
            url: 'addGame.php', 
            type: 'POST', 
            data: 'side=' + side + '&steamid=' + steamid + '&amount=' + amount, 
            dataType: 'text', 
            success: function (data) 
            {
                document.getElementById('game-alert').innerHTML = data;
                $("#game-alert").fadeIn();
                refreshGames();
                document.getElementById('createGameButton').innerHTML = 'Create Game';
            }
        });
    }

    if(buttonText=='Create Game')
    {
        document.getElementById('createGameButton').innerHTML = 'Are you sure?';
    }
}

1 个答案:

答案 0 :(得分:0)

$( "#createGameButton" ).prop( "disabled", true );