Avoiding jQuery
Hello there! I'm currently working on implementing multiple Event Listeners for a button.
function logoContame(){
var logo = document.getElementById("logoheader");
logo.addEventListener("click", hideDivHistorias);
logo.addEventListener("click", showDivPagina2);
}
function showPagina2(){
var historias = document.getElementById("historias");
var hist1 = document.getElementById("hist1");
hist1.id="hist1";
hist1.style.opacity = "0.0";
historias.appendChild(hist1);
var hist2 = document.getElementById("hist2");
hist2.id="hist2";
hist2.style.opacity = "0.0";
historias.appendChild(hist2);
var hist3 = document.getElementById("hist3");
hist3.id="hist3";
hist3.style.opacity = "0.0";
historias.appendChild(hist3);
var textoabrigo= document.getElementById("textoabrigo");
textoabrigo.id="textoabrigo";
textoabrigo.style.opacity = "0.0";
historias.appendChild(textoabrigo);
showHeader();
startFadeInPagina2();
showDivPagina2();
menuPag1();
logoInicial();
}
//Creating Initial Page
function showDivPagina2(){
var div2 = document.getElementById('historias').style.visibility =
"visible";
}
The first event listener is functional, however, the second one seems to be problematic. Is there a solution to this issue? An error message that's continuously appearing is:
Uncaught TypeError: Cannot set property 'id' of null
at showPagina2 (code.js:290)
at HTMLButtonElement.logo1 (code.js:30)
This error seems to be linked to the "hist1" element.
Thank you for your assistance!