0
What problem in my code? I believe the logic is correct!
<h1 id="colorchange">ESTAMOS FAZENDO TESTE DE CORES COM JAVASCRIPT!</h1>
<input type="text" name="Cor" id="whatcolor"><br /><br>
<button type="button" onclick="newcolor('whatcolor')">Mudar</button>
<script>
function newcolor(thecolor) {
document.getElementById('colorchange').style.color = thecolor;
}
</script>
You are apparently defining the color of
colorchange
as being'whatcolor'
and that’s not a valid color. What you tried to do and what you expected to happen?– Woss