2024-12-13 15:04:52 +01:00
|
|
|
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"
|
|
|
|
})
|
|
|
|
);
|
2024-05-22 21:43:49 +02:00
|
|
|
import { S } from "deka-dom-el/signals";
|
2023-12-04 18:19:30 +01:00
|
|
|
function component(){
|
2024-05-22 21:43:49 +02:00
|
|
|
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);
|
|
|
|
}
|