Skip to content

Instantly share code, notes, and snippets.

@davemenninger
Created August 15, 2025 18:31
Show Gist options
  • Save davemenninger/13fd13950cf2093c5710f3826202cc88 to your computer and use it in GitHub Desktop.
Save davemenninger/13fd13950cf2093c5710f3826202cc88 to your computer and use it in GitHub Desktop.
peekaboo button web component
class Derp extends HTMLButtonElement {
connectedCallback() {
this.addEventListener('click', function () {
this.style.display = "none";
console.log(this.textContent + ' all gone...');
this.doHide();
});
}
doHide() {
setTimeout(() => {
console.log(this.textContent + ' peekaboo');
this.style.display = "flow";
}, "3000");
}
}
customElements.define("x-derp", Derp, { extends: "button" });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment