Disable buttons in Javascript

José Carlos 886 Reputation points
2024-03-24T11:21:47.8966667+00:00

I have a small program, which I made for my grandson, which shows an image of an animal, and the person has to guess the animal's name by clicking on the letters that make up the animal's name. These letters are buttons. What is happening? When the person gets the letter right, I deactivate that letter so it doesn't click again. The first time it works perfectly. When the person gets the name right, I change the image and call a routine that enables all the buttons. But this routine isn't working. The letters used in the previous image remain disabled.

The routine that disables the buttons is as follows:

function activateButtons()

{

 const todosButtons = document.querySelectorAll('.teclas button');

 todosButtons.forEach(button => {

 botao.disabled = false;

 });
```}

Because it does not work?

JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
1,009 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.