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

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -