bind:this for DOM Element References
Obtain a reference to a DOM node for imperative interactions.
Getting a DOM Reference
Use bind:this to obtain a reference to a DOM element, similar to useRef in React.
Declare and Bind
Declare a variable, then bind it.
<script>
let inputEl;
</script>
<input bind:this={inputEl} />All lessons in this course
- bind:value for Text Inputs
- bind:checked for Checkboxes
- bind:group for Radio and Checkbox Groups
- bind:this for DOM Element References