* fix: Chinese test suite Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working. * fix: ran script, updated testStrings and solutions
2.8 KiB
2.8 KiB
id, title, required, challengeType, videoUrl, localeTitle
id | title | required | challengeType | videoUrl | localeTitle | |||
---|---|---|---|---|---|---|---|---|
bad87fee1348bd9bedc08826 | Target HTML Elements with Selectors Using jQuery |
|
6 | 使用选择器使用jQuery定位HTML元素 |
Description
document ready function
。现在让我们编写第一个jQuery语句。所有jQuery函数都以$
开头,通常称为dollar sign operator
,或者作为bling
。 jQuery经常选择带有selector
的HTML元素,然后对该元素执行某些操作。例如,让我们使所有button
元素反弹。只需在您的文档就绪函数中添加此代码: $("button").addClass("animated bounce");
请注意,我们已经在后台包含了jQuery库和Animate.css库,以便您可以在编辑器中使用它们。所以你使用jQuery将Animate.css bounce
类应用于你的button
元素。 Instructions
Tests
tests:
- text: 使用jQuery <code>addClass()</code>函数将类<code>animated</code>并<code>bounce</code>回到<code>button</code>元素。
testString: 'assert($("button").hasClass("animated") && $("button").hasClass("bounce"));'
- text: 只使用jQuery将这些颜色添加到元素中。
testString: 'assert(!code.match(/class.*animated/g));'
- text: 你的jQuery代码应该在<code>$(document).ready();</code>功能。
testString: assert(code.match(/\$\(document\)\.ready\(function.*(\s|\n)*.*button.*.addClass.*\);/g));
Challenge Seed
<script>
$(document).ready(function() {
});
</script>
<!-- Only change code above this line. -->
<div class="container-fluid">
<h3 class="text-primary text-center">jQuery Playground</h3>
<div class="row">
<div class="col-xs-6">
<h4>#left-well</h4>
<div class="well" id="left-well">
<button class="btn btn-default target" id="target1">#target1</button>
<button class="btn btn-default target" id="target2">#target2</button>
<button class="btn btn-default target" id="target3">#target3</button>
</div>
</div>
<div class="col-xs-6">
<h4>#right-well</h4>
<div class="well" id="right-well">
<button class="btn btn-default target" id="target4">#target4</button>
<button class="btn btn-default target" id="target5">#target5</button>
<button class="btn btn-default target" id="target6">#target6</button>
</div>
</div>
</div>
</div>
Solution
// solution required