fixed friendly button

This commit is contained in:
ari melody 2024-04-07 00:29:51 +01:00
parent f7f6254016
commit 1fcb473c5f
Signed by: ari
GPG key ID: CF99829C92678188

View file

@ -40,7 +40,9 @@
</p>
<button id="friendly-button">friendly button</button>
<script>
function hook_button() {
const button = document.getElementById("friendly-button");
if (!button) return;
let clicks = 0;
let saved_clicks = window.localStorage.getItem("friendly-button-clicks");
if (saved_clicks) {
@ -51,6 +53,9 @@
button.innerText = `clicked ${++clicks} times!`;
window.localStorage.setItem("friendly-button-clicks", clicks);
});
}
document.addEventListener("ready", hook_button);
document.addEventListener("htmx:load", hook_button);
</script>
</main>
<footer>