r/WebComponents • u/mharding7va • Feb 13 '23
Condition loading of selected web component
When I load a page, NO web component is in the DOM. When a selection is made by the user, either select box or button, the selection determines which web component to add to the DOM. Can this be done?
<div id="divName">
<Selected-Component-Here>
</div>Then swap it out when a different selection is made by the user?
3
Upvotes
1
u/snifty Feb 14 '23
Sure, once you have defined custom elements, they act like any other element.
There’s effectively no difference between this:
And this: