javascript / beginner
Snippet
Two-Way Data Binding
Two-way binding keeps a variable and a form input in sync. Changing the input updates the variable, and updating the variable changes the input value.
snippet.js
1
2
3
4
5
6
<script>let name = '';</script><input bind:value={name} placeholder="Enter name" /><p>Hello {name}!</p>
svelte
Breakdown
1
bind:value={name}
Creates a two-way connection between the input's value and the 'name' variable.