Hello friends I am new to learning HTML I am trying to make a basic website but I can't get a button which changes the sites background and the button text value to work please help!
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
function lightsOff()
{
if (document.getElementbyID("btnLights").value == "Lights Off") {
document.body.style.backgroundColor = "#151515";
document.getElementbyID("btnLights").value = "Lights On";
}
else {
document.body.style.backgroundColor = "#FFFFFF";
document.getElementbyID("btnLights").value = "Lights Off";
}
}
</script>
<center>
<input type="button" id="btnLights" onclick="lightsOff()" value="Lights Off"></input>
</center>
</body>
</html>
I'm sure its just something silly but I am new and need help!
getElementById. Javascript is case sensitive. You're probably getting errors in the console. Check it.