I want to create a 2d array from divs with classes within divs with classes. This code gives me an array as far as I understood, but I can't access my objects in the array, whats wrong?
var frames;
var myElements = [];
var animatedClasses = ["text", "splash"];
for (var i = 0; i < frames.length; i++) {
for (var j = 0; j < animatedClasses.length; j++) {
myElements[[i], [i, [j]]] = frames[i].getElementsByClassName(animatedClasses[j]);
}
}
myElements[0,0].style.opacity = "0.5"; // DOESN'T WORK
}
<div class="frame">
<div class="splash"></div>
<div class="text"></div>
</div>
<div class="frame">
<div class="splash"></div>
<div class="text"></div>
</div>
myElements[[i], [i, [j]]]I believe you can't do this in javascript. The comma operator should return the last (right) element and ignore the first one. And why is thatjsurrounded in[]? Instead of all this, trymyElements[i][j].