HTML, CSS, JS - wanting to make a dropdown menu stay open / accessing id's from an innerhtml header template

Viewed 23

Im making a webpage and id like to have it so that the menu with subpages stays open after i click on the subpage. The menu is written in a js file, as a template header using innerhtml like such:

const headerTemplate = document.createElement('template');

headerTemplate.innerHTML = `

<style>
    
    /*general settings ... same in default.css ... FROM HERE ...*/
    html {min-height: 100%;}

    * {
        margin: 0;
        padding: 0;
    }

I take it it isnt possible to run js scripts inside this innerhtml code? how could i get around this? I cant even access id's from within this innerhtml.

0 Answers
Related