--- id: bad87fee1348bd9aeda08826 title: Target Elements by id Using jQuery required: - link: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.0/animate.css' challengeType: 6 forumTopicId: 18317 localeTitle: 使用 jQuery 配合 id 选择器选择元素 --- ## Description
你也能通过 id 属性选取标签。 首先,用$("#target3")选择器选取 id 为target3button标签。 注意,和 CSS 属性一样,在 id 名前需要添加#。 然后,用 jQuery 的.addClass()方法添加animatedfadeOut类。 下面的代码的效果是使 id 为target6button标签淡出: $("#target6").addClass("animated fadeOut").
## Instructions
## Tests
```yml tests: - text: 用 jQuery 的addClass()方法给idtarget3button标签添加animated类。 testString: assert($("#target3").hasClass("animated")); - text: 用 jQuery 的addClass()方法给idtarget3的标签的类添加fadeOut类。 testString: assert(($("#target3").hasClass("fadeOut") || $("#target3").hasClass("fadeout")) && code.match(/\$\(\s*.#target3.\s*\)/g)); - text: 仅用 jQuery 给标签设置类。 testString: assert(!code.match(/class.*animated/g)); ```
## Challenge Seed
```html

jQuery Playground

#left-well

#right-well

```
## Solution
```html

jQuery Playground

#left-well

#right-well

```