What are you using? Polymer 2, 3, or LitElement (I strongly urge the latter).
If Polymer, you can access an element with const elem = this.$.[dom_id].... If LitElement, you access an element with const elem = this.shadowRoot.getElementById('[dom_id]') or any querySelector() wish. Once you have access to an item in your element, say a <div>, you can const child = document.createElement('some-element'); // anything you wish elem.appendChild(child); If you are working with Polymer or LitElement, I urge you to join the Polymer Slack channel. Almost no one checks here. On Sunday, January 27, 2019 at 8:12:56 PM UTC-5, Damien Golding wrote: > > I am trying to make a web component that can change the html later. > I tried using the get template method but when I used a variable, it did > not work. It only worked when using a string. The same happened when not > using the html template function and instead just creating my own template > element. > > What causes this to happen? > What is the best practice? > > Additionally, I would like to have a reference to the element so I can do > element.querySelector(subElement). Is the below really the best way to > achieve this? > https://stackoverflow.com/a/43007027/1764521 > Follow Polymer on Google+: plus.google.com/107187849809354688692 --- You received this message because you are subscribed to the Google Groups "Polymer" group. To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/635dc3eb-2090-48c5-902c-6a2a0bfeaedd%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.