поэтому я понял, как заставить код работать, но я не понимаю, почему он работает таким образом
var notaEx = document.getElementById("nota-ex").value;
function calculate () {
console.log(notaEx);
}
<input type="text" id="nota-ex"/>
<button onclick="calculate();">Button</button>
Рабочая версия
var notaEx = document.getElementById("nota-ex");
function calculate () {
console.log(notaEx.value);
}
<input type="text" id="nota-ex"/>
<button onclick="calculate();">Button</butto>
может кто-нибудь объяснить, почему вторая версия работает, а первая нет?