--- id: bad87fee1348bd9aedc08826 title: Target Elements by Class Using jQuery required: - link: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.0/animate.css' challengeType: 6 forumTopicId: 18316 localeTitle: 使用 jQuery 配合 class 选择器选择元素 --- ## Description
我们如何使所有的button标签有弹性的动画效果?我们用$("button")选取所有的button标签,并用.addClass("animated bounce");给其添加一些 CSS 属性。 jQuery 的.addClass()方法用来给标签添加类。 首先,我们使用$(".well")选取类为welldiv标签。 值得注意的是,和 CSS 声明一样,在类名前需要添加.。 然后,用 jQuery 的.addClass()方法添加animatedshake类。 例如,在document ready function中添加下面的代码,能使所有类为text-primary的标签抖动: $(".text-primary").addClass("animated shake");
## Instructions
## Tests
```yml tests: - text: 用 jQuery 的addClass()方法给所有类为well的标签添加animatedshake类。 testString: assert($(".well").hasClass("animated") && $(".well").hasClass("shake")); - 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

```