Answer the question
In order to leave comments, you need to log in
Why doesn't JS work in visual code?
Hello. There is a working code, but in VS Code + open live server it doesn't work. More precisely, javascript does not work at all
var login = document.querySelector(".login-link");
var loginpopup = document.querySelector(".modal-login");
login.addEventListener("click", function (event) {
event.preventDefault();
loginpopup.classList.add("modal-show");
});
var login = document.querySelector('.login-link');
^
ReferenceError: document is not defined
at Object. (h:\barbershop\modal.js:1:13)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader .js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load ( internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Answer the question
In order to leave comments, you need to log in
Good day!
It doesn't appear that your html page is linking to a js file:
Apparently codepen does this automatically.
Turn off what is doing the file synchronization and updating, and then try to do what you are trying.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question