--- 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` 函數。 首先,完成第一個 jQuery 語句。 所有的 jQuery 函數都以 `$` 開頭,這個符號通常被稱爲美元符號(dollar sign operator)或 bling。 jQuery 通常選取並操作帶有選擇器(selector)的 HTML 標籤。 比如,想要給 `button` 元素添加跳躍效果。 只需要在 document ready 函數內添加如下代碼: ```js $("button").addClass("animated bounce"); ``` 請注意,我們已經在後臺引入了 jQuery 庫和 Animate.css 庫,所以你可以在編輯器裏直接使用它們。 你將使用 jQuery 將 Animate.css `bounce` class 應用於 `button` 元素。 # --hints-- 應該用 jQuery 的 `addClass()` 函數給 `button` 元素添加 `animated` 和 `bounce` class。 ```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

```