Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> </head> <body> <script> // The button that says "welcome" on click class WelcomeButton extends HTMLButtonElement { constructor() { super(); this.addEventListener('click', () => alert("welcome")); } } customElements.define('welcome-button', WelcomeButton, { extends: 'button' }); </script> <button is="welcome-button">Click me</button> <button is="welcome-button" disabled>Disabled</button> </body> </html>