custome html element code example
Example 1: create custom html element
class className extends HTMLElement{
contructor(){
super()
this._root = this.attachShadow({mode:"open"})
connectedCallback(){
}
disconnectedCallback(){
}
adoptedCallback(){
}
attributeChangedCallback(nameOfAtr, oldValue, newValue){
}
}
}
window.customElements.define("what you want your tag name to be",class name of tag)
Example 2: create custum tage html
The document.registerElement() method is used to create a custom HTML element. This should be passed as the name of your custom element along with an (optional) object that defines the API.
var XTreehouseElement = document.registerElement('x-treehouse');
document.body.appendChild(new XTreehouseElement());
<x-treehouse></x-treehouse>