I have two HTML files linked to two JS files. I want to save an HTML tag from HTML1 with JS1 in a Variable and export it. Then import it in the JS2 file and use it in HTML2
I have tried many ways but nothing seems to work, something as simple as this
Exporting:
HTML 1
<div id="mainPageCont">
<h2 id="defaultPage" style="text-align: center; margin: auto; width: 100%; height: 200; font-size: large; background-color: blue;">Default Main :))</h2>
</div>
JS 1
let mainPageContainer = document.getElementById("mainPageCont")
export default mainPageContainer;
Importing:
HTML 2
<div id="main-container"></div>
JS 2
import mainPageContainer from './Pages/Main/mainScripts.js'
document.querySelector("#main-container").innerHTML = mainPageContainer