FCC Challenge 34: Check Radio Buttons and Checkboxes by Default
March 14, 2016
In Free Code Camp Challenge 34 we learn to preselect radio buttons and checkboxes by default.
You can set a checkbox or radio button to be checked by default using the checked attribute.
To do this, just add the word “checked” to the inside of an input element. For example:
[html]
[/html]
Set the first of your radio buttons and the first of your checkboxes to both be checked by default.
The original code is below:
[html]
CatPhotoApp
Click here for cat photos.
Things cats love:
- cat nip
- laser pointers
- lasagna
Top 3 things cats hate:
- flea treatment
- thunder
- other cats
The updated code with preselected radio button and checkbox is below:
[html highlight=”47,49″]
CatPhotoApp
Click here for cat photos.
Things cats love:
- cat nip
- laser pointers
- lasagna
Top 3 things cats hate:
- flea treatment
- thunder
- other cats