I have the following function that reset
s a button
and applies styling once it is executed:
function reset(){
var boxes = getBoxes();
for(i = 0 ; i < boxes.length; i++) {
boxes[i].innerHTML = "";
}
document.getElementById("start_button").innerHTML = "Start Game";
document.getElementById("start_button").setAttribute('onclick', 'gameStart()');
document.getElementById("start_button").style.color = "black";
document.getElementById("start_button").style.backgroundColor = "lightgreen";
}
However, as you can see, it is getting repetitive to change each style element in the function. Especially if I want this style to be applied:
#button{
text-align: center;
}
#start_button{
width: 10%;
height: 50px;
margin-top: 4%;
margin-left: auto;
margin-right: auto;
background: lightgreen;
color:black;
}
#start_button:hover {
background: green;
color: white;
}
Is there a way in JavaScript to link to an entire block of style code?