Кнопка не работает

Почему кнопка не работает? Ошибок в консоль не выводит

function init() {
  var fireButton = document.getElementById('#fireButton');
  fireButton.onclick = handleFireButton;
}

function handleFireButton() {
  var guessInput = document.getElementById('#guessInput');
  var guess = guessInput.value;
  controller.processGuess(guess);
  guessInput.value = "";
}

window.onload = init;
<form>
  <input type="text" id="guessInput" placeholder="A0">
  <input type="button" id="fireButton" value="Fire!">
</form>


Ответы (1 шт):

Автор решения: xydope
  • в getElementById не надо указывать знак решетки #;
  • init в конце надо вызвать;

function init() {
  var fireButton = document.getElementById('fireButton');
  fireButton.onclick = handleFireButton;
}

function handleFireButton() {
  var guessInput = document.getElementById('guessInput');
  var guess = guessInput.value;
//вставьте ваш код
  alert(guess)
}
//вызываем инит
init()
<form>
  <input type="text" id="guessInput" placeholder="A0">
  <input type="button" id="fireButton" value="Fire!">
</form>

→ Ссылка