mirror of
https://github.com/kou029w/_.git
synced 2025-01-30 22:08:02 +00:00
9 lines
280 B
TypeScript
9 lines
280 B
TypeScript
export function setupCounter(element: HTMLButtonElement) {
|
|
let counter = 0;
|
|
const setCounter = (count: number) => {
|
|
counter = count;
|
|
element.innerHTML = `count is ${counter}`;
|
|
};
|
|
element.addEventListener("click", () => setCounter(counter + 1));
|
|
setCounter(0);
|
|
}
|