To stay organised whilst fetching a lot of DOM elements, I'm trying to store these in an object. (I may be adding DOM methods later)
Why can't I reference a property and get it's child after it's declared?
const DOM = {
container: document.querySelector('.quiz'),
question: this.container.children[0],
labels: Array.from(document.querySelectorAll('.quiz__answer--label')),
input: this.labels[0]
};
When 'container' and 'labels' are called by other properties they are undefined, why is this?
Is there any particular method good for organising a lot of DOM elements or is it best just to store them in variables?