Svelte · Junior · Frage 67 von 76
Wie baut man eine an ein Array gebundene Gruppe von Checkboxen?
<script>
let toppings = $state([]);
</script>
<input type="checkbox" value="cheese" bind:group={toppings} />
<input type="checkbox" value="ham" bind:group={toppings} />- 1
bind:groupan jeder Checkbox - 2
bind:checkedmit dem ganzen Array - 3
bind:valuemit dem ganzen Array
Antwort zeigen
Richtige Antwort: bind:group an jeder Checkbox
Erklärung
Bei Radio-Buttons hält bind:group einen einzelnen Wert statt eines Arrays.