--- id: bad87fee1348bd9bedc08826 title: 使用 jQuery 选择器选择元素 challengeType: 6 forumTopicId: 18319 required: - link: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.0/animate.css' dashedName: target-html-elements-with-selectors-using-jquery --- # --description-- 现在已经有了 `document ready function`。 首先,完成第一个 jQuery 语句。 所有的 jQuery 函数都以 `$` 开头,这个符号通常被称为美元符号(dollar sign operator)或 bling。 jQuery 通常选取并操作带有选择器(selector)的 HTML 标签。 比如,想要给 `button` 元素添加跳跃效果。 只需要在 document ready 函数内添加如下代码: `$("button").addClass("animated bounce");` 请注意,已经在后台引入了 jQuery 库和 Animate.css 库,所以可以在编辑器里直接使用 jQuery 和动画。 因此,只需要通过 jQuery 给 `button` 元素添加 `bounce` 类就可以了。 # --hints-- 应该用 jQuery 的 `addClass()` 方法给 `button` 标签添加 `animated` 和 `bounce` 类。 ```js assert($('button').hasClass('animated') && $('button').hasClass('bounce')); ``` 应该仅用 jQuery 给标签添加这些 class。 ```js assert(!code.match(/class.*animated/g)); ``` jQuery 代码应该放在 `$(document).ready();` 函数里。 ```js assert( code.replace(/\s/g, '').match(/\$\(document\)\.ready\(function\(\)\{\$/g) ); ``` # --seed-- ## --seed-contents-- ```html

jQuery Playground

#left-well

#right-well

``` # --solutions-- ```html

jQuery Playground

#left-well

#right-well

```