+ 3
Help with color input
Why is the word “hello” not changing color when I pick a color? And why am I console logging #000000 no matter what color I select? https://sololearn.com/compiler-playground/Wk8HrWduxZRT/?ref=app Thanks
3 Respuestas
+ 2
The correct way to write this code is:
const e = document.getElementById("q");
const box = document.getElementById("box");
const changeclr=()=>{
console.log(e.value);
box.style.color=e.value;
}
+ 1
SoloProg
unfortunately, the inline function call in the html tab would still fail to find the javascript function in the javascript tab.
one way is to migrate the js and put it in the html tab as internal js.
The other way is to assign the eventListener in the javascript tab.
+ 1
in sololearn by default js code is placed in header
so, when this script get executed elements are not created. use window.onload
when you set onclick = function, function must be defind before rendering the element. so you cannot place function inside window.onload