Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

189
Visualizações
OnMouseDown function to remove disabled Attribute from buttons in Javascript

I am working on a game that allows users to select which letters they want to use for the game. Each letter is a button identical to the one below, with disabled = true.

<button id = "a" disabled = "true" style={{ fontSize: '8vh', height: '100%', width: '8%', cursor: 'pointer' }} 
     onMouseDown={function () {
          var a= "A";
          addToDisplayList(a);
     }}>
     A
</button>

Before the user can select the letters, they must click the Select Letters button which resets the array that holds the selected letters and removes the disable attribute from all the letter buttons. The code for the Select Letters button is below.

<button id = "clear" style={{ fontSize: '8vh', height: '100%', cursor: 'pointer' }}
       onMouseDown={function () {
            setToZero();
            for(var i=0; i<letterList.length; i++){
                 document.getElementById(letterList.charAt(i)).removeAttribute("disabled");
            }
}}>
Select Letters
</button>

When I click Select Letters to remove the disabled attribute from all the letter buttons, they become ungreyed out and seem to be enabled. However when I click any of the letter buttons, they do not run their onMouseDown functions.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda