vendredi 16 septembre 2016

How to know if a checkbox is checked?

Here is the code:

<input type="checkbox" value="Blue" (click)="var=$event.target.getAttribute('value')" />

When i to print var on console, i get the value of the checkbox 'Blue' but what if i want to get if the checkbox is checked or not?

I have tried this but i get undefined:

<input type="checkbox" value="Blue" (click)="var=$event.target.getAttribute('checked')" />




Aucun commentaire:

Enregistrer un commentaire