skip to Main Content

How to append a created html element to another html file?

const button1 = document.getElementById('1'); const button2 = document.getElementById('2'); const main = document.getElementById('main'); function myFunc() { const elem = document.createElement('h1'); button1.onclick = () => { location.assign('2.html'); elem.textContent = '1'; if (location.pathname === '/2.html') { main.appendChild(elem); } } button2.onclick = () =>…

VIEW QUESTION
Back To Top
Search