working on JS after a couple years, I'm a bit rusty, but why isn't appendChild not working properly?
context, basically what this should create is
one back to top button
one hamburger button that opens a div that contains a navigation menu
//code that create both buttons here //some extract const navBtn = document.createElement('button'); navBtn.className = 'gallery-nav-btn'; navBtn.textContent = '☰'; navBtn.setAttribute('aria-label', 'Jump to section'); /// other button const topBtn = document.createElement('button'); topBtn.className = 'gallery-nav-btn'; topBtn.textContent = '↑'; topBtn.setAttribute('aria-label', 'Back to top'); topBtn.style.marginBottom = '8px'; topBtn.addEventListener('click', () => { window.scrollTo({ top: 0, behavior: 'smooth' }); }); //Similar structure for the second button except it's a 'back to top button' //now to append navDiv.appendChild(topBtn); // back to top button navWrap.appendChild(popup); // then the popup with the div nav menu navWrap.appendChild(navBtn); // then the hamburger/nav button document.body.appendChild(navWrap);
what is rendered?
only the nav button and the popup, for some reason the back to top button doesn't render, it is there because I can inspect, and the appended button is there, it's not a CSS issue because I turned off all the CSS and they are not overlapping
it's really bugging me that I cannot figure out why the button doesn't show up, even if I comment out navWrap.appendChild(navBtn);the other button doesn't show up
u/Book-Parade — 1 day ago