generate functionThu, 12 Jan 2023

subMenuEl’s event listener should update the contents of mainEl to the contents of the <a> element, within an <h1>, clicked within subMenuEl.

const subMenuEl = document.querySelector("#sub-menu") const mainEl = document.querySelector("#main") subMenuEl.addEventListener("click", function(event) { const h1El = document.createElement("h1") h1El.innerHTML = mainEl.innerHTML = "" mainEl.appendChild(h1El) })

Generate More

Questions about programming?Chat with your personal AI assistant