Bind Value In Svelte – Code Example

In Svelte binding works differently and it’s two-way binding. In Svelte you don’t need any function or method to handle the input event as we…

The post Bind Value In Svelte – Code Example appeared first on CodeSource.io.


This content originally appeared on CodeSource.io and was authored by Jatin Hemnani

In Svelte binding works differently and it’s two-way binding. In Svelte you don’t need any function or method to handle the input event as we do in React.

<script>
    let name=''
</script>

<input type=text bind:value={name} placeholder="Enter Name" />
<h2>
   Your Name is {name}
</h2>

Here we have a variable as name with an empty string and in HTML we have <input> with bind of the variable name and that’s it. You have now successfully bind the value to the input.

Result Of Above Code

1.

Bind Value In Svelte
Bind Value In Svelte

The post Bind Value In Svelte – Code Example appeared first on CodeSource.io.


This content originally appeared on CodeSource.io and was authored by Jatin Hemnani


Print Share Comment Cite Upload Translate Updates
APA

Jatin Hemnani | Sciencx (2021-02-18T12:39:50+00:00) Bind Value In Svelte – Code Example. Retrieved from https://www.scien.cx/2021/02/18/bind-value-in-svelte-code-example/

MLA
" » Bind Value In Svelte – Code Example." Jatin Hemnani | Sciencx - Thursday February 18, 2021, https://www.scien.cx/2021/02/18/bind-value-in-svelte-code-example/
HARVARD
Jatin Hemnani | Sciencx Thursday February 18, 2021 » Bind Value In Svelte – Code Example., viewed ,<https://www.scien.cx/2021/02/18/bind-value-in-svelte-code-example/>
VANCOUVER
Jatin Hemnani | Sciencx - » Bind Value In Svelte – Code Example. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/02/18/bind-value-in-svelte-code-example/
CHICAGO
" » Bind Value In Svelte – Code Example." Jatin Hemnani | Sciencx - Accessed . https://www.scien.cx/2021/02/18/bind-value-in-svelte-code-example/
IEEE
" » Bind Value In Svelte – Code Example." Jatin Hemnani | Sciencx [Online]. Available: https://www.scien.cx/2021/02/18/bind-value-in-svelte-code-example/. [Accessed: ]
rf:citation
» Bind Value In Svelte – Code Example | Jatin Hemnani | Sciencx | https://www.scien.cx/2021/02/18/bind-value-in-svelte-code-example/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.