I am trying to change the circle size when entering a value in the input, and trying to change the color. But I am getting the following error:
Cannot set properties of undefined (setting 'css')
Can any of you be helpfull with what i can do?
window.addEventListener("DOMContentLoaded", (event) => {
const inputsize = document.getElementById("size");
const inputcolor = document.getElementById("color");
const circle = document.getElementsByClassName("circle");
let size = 100;
let color = "#b66465";
window.onchange = (event) => {
let myStyles = "height: " + size + "px; width: " + size + "px; background-color: " + color + ";";
circle.style.css = myStyles;
};
inputcolor.onchange = (event) => {
color = inputcolor.value;
let myStyles = "height: " + size + "px; width: " + size + "px; background-color: " + color + ";";
circle.style.css = myStyles;
};
inputsize.onkeyup = (event) => {
size = inputsize.value;
let myStyles = "height: " + size + "px; width: " + size + "px; background-color: " + color + ";";
circle.style.css = myStyles;
};
});