DEV Community

Lam Hoang
Lam Hoang

Posted on

Handle Events in Svelte

<button on:click={handleClick}>
  Press me
</button>

<button on:click={() => console.log('I was pressed')}>
  Press me
</button>

<button on:click|once={handleClick}>
  Press me
</button>

<button on:submit|preventDefault={handleClick}>
  Press me
</button>
Enter fullscreen mode Exit fullscreen mode

Svelte Cheat Sheet

Top comments (0)