- Joined
- Sep 12, 2022
- Messages
- 39
- Reaction score
- 0
If I move the variable inside of the function, the code executes but once I move it outside of the function it doesn't. Why?
HTML:
<input id="pp" type=text></input>
<button id="button">Start</button>
JavaScript:
const pp = document.querySelector("input").value;
ks = () => {
console.log(pp);
}
document.querySelector("#button").addEventListener('click', ks)