I have the folowing code:
var transitionsSettingsClass = document.getElementsByClassName("transitionsSettings");
var transitionsSettingsClassLenght = transitionsSettingsClass.length;
for (i=0; i < transitionsSettingsClassLenght; i++);
{
transitionsSettingsClass[i].setAttribute("data-transition",transitionsSettings);
};
I know that transitionsSettingsClassLenght = 6 because I have checked it with alert. But when I put an alert inside cycle then it shows only 1-time (it should show 6-times). An also attribute data-transition is not set. But when I replace “i” inside transitionsSettingsClass[i] with transitionsSettingsClass[0] my first element changes and it is working. This script is supposed to change attribute data-transition in 6 elements.
Remove the
;at the end ofThe
forhere only commands the code before the;, that is nothing.I’d recommend you to use the most frequent javascript style, as explicited by Google, as it helps avoid this kind of errors.