fixed friendly button
This commit is contained in:
parent
f7f6254016
commit
1fcb473c5f
|
@ -40,7 +40,9 @@
|
||||||
</p>
|
</p>
|
||||||
<button id="friendly-button">friendly button</button>
|
<button id="friendly-button">friendly button</button>
|
||||||
<script>
|
<script>
|
||||||
|
function hook_button() {
|
||||||
const button = document.getElementById("friendly-button");
|
const button = document.getElementById("friendly-button");
|
||||||
|
if (!button) return;
|
||||||
let clicks = 0;
|
let clicks = 0;
|
||||||
let saved_clicks = window.localStorage.getItem("friendly-button-clicks");
|
let saved_clicks = window.localStorage.getItem("friendly-button-clicks");
|
||||||
if (saved_clicks) {
|
if (saved_clicks) {
|
||||||
|
@ -51,6 +53,9 @@
|
||||||
button.innerText = `clicked ${++clicks} times!`;
|
button.innerText = `clicked ${++clicks} times!`;
|
||||||
window.localStorage.setItem("friendly-button-clicks", clicks);
|
window.localStorage.setItem("friendly-button-clicks", clicks);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
document.addEventListener("ready", hook_button);
|
||||||
|
document.addEventListener("htmx:load", hook_button);
|
||||||
</script>
|
</script>
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
<footer>
|
||||||
|
|
Loading…
Reference in a new issue