I want to change CSS property background color using class name in JavaScript. My code is as below
function changeColor(){
document.getElementsByClassName("flex-items").style.backgroundColor = "blue";
}
The function changeColor() is called with a onclick event of a button.
<button onclick="changeColor()">Change Color</button>
Is there a solution to this problem?
[Note there are many div boxes with class name "flex-items" and I want to change all their background color on a single click.]