Counter

Increment and decrement values
Learn how to modify numeric values with hyperscript's increment and decrement commands.
increment decrement numbers
0

Current value: 0

The Code

<div id="count" class="counter-display">0</div> <button _="on click decrement #count"> Decrease </button> <button _="on click put 0 into #count"> Reset </button> <button _="on click increment #count"> Increase </button>

How it works:

Advanced Increment/Decrement:

Reactive Updates:

The count mirror below the buttons uses: on change in #count to reactively update whenever the counter changes! This pattern watches for content changes in the #count element and automatically mirrors the value.

Try it yourself: