1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2025-01-18 23:43:15 +01:00

21 lines
554 B
JavaScript
Raw Permalink Normal View History

import { el, on } from "deka-dom-el";
/** @param {HTMLElement} el */
const empty= el=> Array.from(el.children).forEach(c=> c.remove());
2023-12-04 18:19:30 +01:00
document.body.append(
el(component),
el("button", {
textContent: "Remove",
onclick: ()=> empty(document.body),
type: "button"
})
);
import { S } from "deka-dom-el/signals";
2023-12-04 18:19:30 +01:00
function component(){
const textContent= S("Click to change text.");
2023-12-04 18:19:30 +01:00
const onclickChange= on("click", function redispatch(){
textContent("Text changed! "+(new Date()).toString())
});
return el("p", textContent, onclickChange);
}