2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
id: bad87fee1348bd9aec908852
|
|
|
|
title: Create a Class to Target with jQuery Selectors
|
|
|
|
challengeType: 0
|
2020-09-07 16:17:39 +08:00
|
|
|
forumTopicId: 16815
|
|
|
|
localeTitle: 分别给每个目标元素的 class 属性添加一个 target 值
|
2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
|
|
|
|
## Description
|
2020-09-07 16:17:39 +08:00
|
|
|
<section id='description'>
|
|
|
|
并不是所有 class 属性都需要有对应的 CSS 样式。有时候我们设置 class 只是为了更方便地在 jQuery 中选中这些元素。
|
|
|
|
为每一个 <code>button</code> 元素添加 <code>target</code> class。
|
|
|
|
</section>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
## Instructions
|
2020-09-07 16:17:39 +08:00
|
|
|
<section id='instructions'>
|
|
|
|
|
2018-10-10 18:03:03 -04:00
|
|
|
</section>
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
```yml
|
|
|
|
tests:
|
2020-09-07 16:17:39 +08:00
|
|
|
- text: 给你的每一个 <code>button</code> 元素设置 <code>target</code> class。
|
2020-02-18 01:40:55 +09:00
|
|
|
testString: assert($(".target").length > 5);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
<div id='html-seed'>
|
|
|
|
|
|
|
|
```html
|
|
|
|
<div class="container-fluid">
|
|
|
|
<h3 class="text-primary text-center">jQuery Playground</h3>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-xs-6">
|
|
|
|
<div class="well">
|
|
|
|
<button class="btn btn-default"></button>
|
|
|
|
<button class="btn btn-default"></button>
|
|
|
|
<button class="btn btn-default"></button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-xs-6">
|
|
|
|
<div class="well">
|
|
|
|
<button class="btn btn-default"></button>
|
|
|
|
<button class="btn btn-default"></button>
|
|
|
|
<button class="btn btn-default"></button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
```
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
<section id='solution'>
|
|
|
|
|
2020-09-07 16:17:39 +08:00
|
|
|
```html
|
|
|
|
<div class="container-fluid">
|
|
|
|
<h3 class="text-primary text-center">jQuery Playground</h3>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-xs-6">
|
|
|
|
<div class="well">
|
|
|
|
<button class="target btn btn-default"></button>
|
|
|
|
<button class="target btn btn-default"></button>
|
|
|
|
<button class="target btn btn-default"></button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-xs-6">
|
|
|
|
<div class="well">
|
|
|
|
<button class="target btn btn-default"></button>
|
|
|
|
<button class="target btn btn-default"></button>
|
|
|
|
<button class="target btn btn-default"></button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-10-10 18:03:03 -04:00
|
|
|
```
|
2020-08-13 17:24:35 +02:00
|
|
|
|
2020-09-07 16:17:39 +08:00
|
|
|
</section>
|