I am interested in knowing how to have the function already loaded when entering the page without having to click on a button or load it in the body
function color(){
var x = document.getElementById("box");
x.className = "cajas";
}
.cajas{
background-color: #ddd;
display: flex;
justify-content: space-between;
}
.cajas > span{
width: 50px;
height: 50px;
background-color: blue;
display: block;
}
<div id="box">
<span></span>
<span></span>
<span></span>
</div>
<button onclick="color()">Color</button>
Simply call the function after declaring it.
The HTML that the browser receives looks like this: