Svelte · Junior · Question 21 of 76
How do you handle a click in Svelte 5?
- ✓Correct answer:
<button onclick={handleClick}> - 2
<button on:click={handleClick}>only - 3
<button @click="handleClick">
Explanation
In Svelte 5 events are plain attributes starting with on. The on:click directive is the legacy Svelte 4 syntax.