---
id: bad87fee1348bd9aedd08835
title: Check Radio Buttons and Checkboxes by Default
challengeType: 0
videoUrl: 'https://scrimba.com/p/pVMPUv/cWk3Qh6'
forumTopicId: 301094
localeTitle: 给单选按钮和复选框添加默认选中项
---
## Description
如果想设置某个单选按钮或多选按钮默认被选中,只需给input
元素添加 "checked" 属性。 例如:
<input type="radio" name="test-name" checked>
## Instructions
把第一个radio button
和第一个checkbox
都设置为默认选中。
## Tests
```yml
tests:
- text: '表单的第一个单选按钮应该被默认选中。'
testString: assert($('input[type="radio"]').prop("checked"));
- text: '表单的第一个多选按钮应该被默认选中。'
testString: assert($('input[type="checkbox"]').prop("checked"));
```
## Challenge Seed
```html
CatPhotoApp
点击查看更多猫咪图片。
猫咪最喜欢的三件东西:
猫咪最讨厌的三件东西:
- 跳蚤
- 打雷
- 同类
```
## Solution