Complete the code to bind the width of the div to the variable width.
<script> let width = 0; </script> <div bind:[1]={width} style="background: lightblue; height: 100px;"> Width: {width}px </div>
In Svelte, bind:clientWidth binds the element's width to the variable.
Complete the code to bind the height of the section to the variable height.
<script> let height = 0; </script> <section bind:[1]={height} style="background: lightgreen; width: 200px;"> Height: {height}px </section>
Binding clientHeight updates the variable with the element's height.
Fix the error in the code to correctly bind the width of the div to boxWidth.
<script> let boxWidth = 0; </script> <div bind:[1]={boxWidth} style="background: coral; height: 150px;"> Box width: {boxWidth}px </div>
The correct binding for width is clientWidth. Using clientHeight or others will not bind width.
Fill both blanks to bind width and height of the article to width and height variables.
<script> let width = 0; let height = 0; </script> <article bind:[1]={width} bind:[2]={height} style="background: lightyellow;"> Size: {width}px wide and {height}px tall </article>
Use bind:clientWidth for width and bind:clientHeight for height bindings.
Fill all three blanks to create a reactive statement that updates area when width or height changes.
<script> let width = 0; let height = 0; let area = 0; $: area = [1] * [2]; </script> <div bind:clientWidth={width} bind:clientHeight={height} style="background: lavender;"> Area: {area} px² </div>
The reactive statement multiplies width and height to update area.