javascript - Disabling Anchor Buttons -
i need making anchor button not clickable after has been clicked once before.
any appreciated in advance
html code:
<div class="text-center"> <a role="button" class="btn btn-success" id="creategamebutton" onclick="addgame();">create coinflip</a> </div>
javascript code:
function addgame() { var side = $("#side").val(); var steamid = $("#steamid").val(); var amount = $("#amount").val(); var buttontext = document.getelementbyid('creategamebutton').innerhtml; if(buttontext=='create coinflip') { $.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 coinflip'; } }); } }
remove onclick="addgame();"
, use one
.one()
attach handler event elements. handler executed @ once per element per event type.
so:-
$('#creategamebutton').one("click", addgame);
Comments
Post a Comment