Share:

What Is The Best Way To Define HTML Custom Element? | Web Components | Amit Padhiyar (Saatody)

Define class with class name and outside of the define() function is the best way to create custom element.
<script>
    class HelloMSG extends HTMLElement{
        constructor(){
            super();
            console.log("constructor");
        }
    }
    window.customElements.define("hello-msg",HelloMSG);
</script>
There is one thing that prove why i recommended to define HTML custom element like this.
<script>
    const msg = new HelloMSG();
    document.body.appendChild(msg);
</script>
For append my HTML custom element using JavaScript.







Comments

Popular posts from this blog

Get Color From Pixel C# WPF | Saatody | Amit Padhiyar

Basic Audio Operations With MP3 And Wave Files Using NAudio C#

Create Drag And Drop Operation Between DevExpress GridControl And Custom WPF UI | Saatody | Amit Padhiyar