I\'m performing a small text with JavaScript with the getElementsByClassName() and I am getting some unwanted results. I would like the script to change each CS
This worked for me
var blockSet = document.getElementsByClassName("block-default");
var blockSetLength = blockSet.length;
blockSet[0].className = "block-selected";
blockSet[0].className = "block-selected";
blockSet[0].className = "block-selected";
blockSet[0].className = "block-selected";
blockSet[0].className = "block-selected";
blockSet[0].className = "block-selected";
blockSet[0].className = "block-selected";
blockSet[0].className = "block-selected";
.block-default {
width: 100px;
height:50px;
background-color: green;
border: 1px solid red;
padding:10px;
}
.block-selected {
width: 100px;
height:50px;
background-color: blue;
border: 1px solid white;
padding:10px;
}
BLOCK1
BLOCK2
BLOCK3
BLOCK4
BLOCK5
BLOCK6
BLOCK7
BLOCK8