91 lines
2.1 KiB
Markdown
91 lines
2.1 KiB
Markdown
---
|
|
id: bad87fee1348bd9aec908852
|
|
title: Create a Class to Target with jQuery Selectors
|
|
challengeType: 0
|
|
forumTopicId: 16815
|
|
localeTitle: 分别给每个目标元素的 class 属性添加一个 target 值
|
|
---
|
|
|
|
## Description
|
|
<section id='description'>
|
|
并不是所有 class 属性都需要有对应的 CSS 样式。有时候我们设置 class 只是为了更方便地在 jQuery 中选中这些元素。
|
|
为每一个 <code>button</code> 元素添加 <code>target</code> class。
|
|
</section>
|
|
|
|
## Instructions
|
|
<section id='instructions'>
|
|
|
|
</section>
|
|
|
|
## Tests
|
|
<section id='tests'>
|
|
|
|
```yml
|
|
tests:
|
|
- text: 给你的每一个 <code>button</code> 元素设置 <code>target</code> class。
|
|
testString: assert($(".target").length > 5);
|
|
|
|
```
|
|
|
|
</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'>
|
|
|
|
```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>
|
|
```
|
|
|
|
</section>
|