I have the following piece of code:
var cta = document.querySelector('.cta');
In Chrome / Opera it returns the element correctly, only in Firefox it is returned the error:
TypeError: cta is null
Does anyone know what it can be?
I'm calling it via:
window.addEventListener('load', () => {
cta.style.opacity = 1;
});
Complete code:
var cta = document.querySelector('.cta');
function box() {
if(cta) {
var vitrine = [].slice.call(document.querySelectorAll('.vitrine'));
for(var i = 0; i < vitrine.length; i++) {
vitrine[i].style.height = window.getComputedStyle(vitrine[i]).width;
}
}
}
box();
window.addEventListener('load', () => {
cta.style.opacity = 1;
});
window.addEventListener('resize', () => box());