0
Hello
I need to change the background color of a div, I’m trying but it doesn’t work which may be wrong ?
My code:
window.onresize = function() {
var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
if (w < 800) {
getElementById("top").style.background-color = "#FFFFFF";
}
};
Thank you
When you want to manipulate some element of the DOM(Document Object Model) you first need to access it right? In case the document, ie, Document.getElementById(...
– LeAndrade
In addition to the @Leandrade comment, you need to change the
style.background-color
forstyle.backgroundColor
– Colasanto
Thank you so much for your help.
– user171274