V
V
Vladislav Tseplyaev2020-02-16 15:02:00
JavaScript
Vladislav Tseplyaev, 2020-02-16 15:02:00

Why is the JavaScript console not working in Vs code?

let page = document.querySelector('.page');
page.classList.remove('light-theme');
page.classList.add('dark-theme');

let themeButton = document.querySelector('.theme-button');
themeButton.onclick = function () {
  console.log('Кнопка нажата!');  
};
Не выводится сообщение в консоль. Что делать?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tigran Abrahamyan, 2020-02-16
@Frint

Try this, and go to the browser console and not the editor.
With your code, it was displayed in my browser, so it's working.

themeButton.addEventListener("click", function() {
  console.log('Кнопка нажата!');
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question