I am seeking a solution to change the background color of multiple div boxes with the class name "flex-items" using JavaScript. Below is my current code:
function changeColor(){
document.getElementsByClassName("flex-items").style.backgroundColor = "blue";
}
The function changeColor() is triggered by an onclick event from a button.
<button onclick="changeColor()">Change Color</button>
Is there a way to modify this code so that all the div boxes with the class name "flex-items" change their background color simultaneously with a single click?