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
You have already some good solutions.
I think that the best one is the one from Rick Hitchcock.
But a solution that I often use, to be safe when doing things like that, is to travel the collection backwards
var nmax = blockSet.length - 1;
for (var n=nmax; n>=0; n--) {
blockSet[n].className = 'block-selected';
}
That isolates you from changes in the collection