Question · Svelte and SvelteKit course · Module 1: Introduction to Svelte
Combining preventDefault and stopPropagation
How do you stop both the default action and the propagation of an event in Svelte 5?
Answer options
- Call event.preventDefault() and event.stopPropagation() in the handler function
- onclick|preventDefault|stopPropagation={handler}
- onclick.preventDefault.stopPropagation={handler}
- onclick={handler} preventDefault stopPropagation
Show the answer
Correct answer:
- Call event.preventDefault() and event.stopPropagation() in the handler function