--- id: bad87fee1348bd9aed008826 required: - link: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.0/animate.css' challengeType: 6 forumTopicId: 18318 title: 使用 jQuery 选择偶数元素 --- ## Description
你也可以用基于位置的:odd:even选择器选取标签。 注意,jQuery 是零索引(zero-indexed)的,这意味着第 1 个标签的位置编号是0。这有点混乱和反常——:odd表示选择第 2 个标签(位置编号 1),第 4 个标签(位置编号 3)……等等,以此类推。 下面的代码展示了选取所有的奇标签并设置类: $(".target:odd").addClass("animated shake"); 请尝试选取所有target标签的偶标签并给他们设置animatedshake类。要考虑到偶(even)指的是标签位置编号基于0的系统。
## Instructions
## Tests
```yml tests: - text: 所有的target标签应该抖动。 testString: assert($('.target:even').hasClass('animated') && $('.target:even').hasClass('shake')); - text: 应该用:even选择器修改这些标签。 testString: assert(code.match(/\:even/g)); - text: 仅用 jQuery 给标签添加类。 testString: assert(code.match(/\$\(".target:even"\)/g) || code.match(/\$\('.target:even'\)/g) || code.match(/\$\(".target"\).filter\(":even"\)/g) || code.match(/\$\('.target'\).filter\(':even'\)/g)); ```
## Challenge Seed
```html

jQuery Playground

#left-well

#right-well

```
## Solution
```html

jQuery Playground

#left-well

#right-well

```