skip to Main Content

Html – Why doesn't document.getElementById work within a function

`Why does it work outside the function tho? What's wrong? I dont get it... Tried adding return statemnts - still nothing. [[enter image description here](https://phpout.com/wp-content/uploads/2023/09/ZWAvj.png)](https://phpout.com/wp-content/uploads/2023/09/HteFI.png) DOESN'T WORK: function changeValue() { let charge = document.getElementById("myRange").value; document.getElementById("displayValue").innerHTML = charge; } WORKS: let…

VIEW QUESTION

Html – Why am I getting "NaN" here?

I'm trying to make a simple calculator, however, when I try to add two numbers, I'm getting the NaN result. Before this problem, the function sumar() was returning [object HTMLInputElement][object HTMLInputElement], however after adding + when calling the dom, it…

VIEW QUESTION
Back To Top
Search