diff --git a/curriculum/challenges/chinese/03-front-end-libraries/jquery/change-text-inside-an-element-using-jquery.chinese.md b/curriculum/challenges/chinese/03-front-end-libraries/jquery/change-text-inside-an-element-using-jquery.chinese.md index 7478ef7b87..6b8623b08e 100644 --- a/curriculum/challenges/chinese/03-front-end-libraries/jquery/change-text-inside-an-element-using-jquery.chinese.md +++ b/curriculum/challenges/chinese/03-front-end-libraries/jquery/change-text-inside-an-element-using-jquery.chinese.md @@ -2,15 +2,25 @@ id: 564944c91be2204b269d51e3 title: Change Text Inside an Element Using jQuery challengeType: 6 -videoUrl: '' -localeTitle: 使用jQuery更改元素内的文本 +forumTopicId: 16773 +localeTitle: 使用 jQuery 更改元素内部的文本 --- ## Description -
使用jQuery,您可以更改元素的开始和结束标记之间的文本。您甚至可以更改HTML标记。 jQuery有一个名为.html()的函数,它允许您在元素中添加HTML标记和文本。之前在元素中的任何内容都将完全替换为您使用此功能提供的内容。以下是重写和强调标题文本的方法: $("h3").html("<em>jQuery Playground</em>"); jQuery也有一个类似的函数.text() ,它只改变文本而不添加标签。换句话说,此函数不会评估传递给它的任何HTML标记,而是将其视为要替换现有内容的文本。通过强调其文本来更改id为target4的按钮。查看此链接以了解有关<i><em>之间的区别及其用途的更多信息。请注意,虽然<i>标签传统上一直用于强调文本,但它已被合并用作图标标签。 <em>标签现在被广泛接受为强调标签。两者都可以应对这一挑战。
+
+你能用 jQuery 改变起始标签和结束标签之间的文本,甚至改变 HTML 标签。 +jQuery 有一个.html()函数,你能用其在标签里添加 HTML 标签和文本,函数提供的内容将完全替换之前标签的内容。 +下面的代码效果是重写并强调标题文本: +$("h3").html("<em>jQuery Playground</em>"); +类似的,jQuery 有一个.text()函数,其改变文本而不增加标签。换而言之,该函数会忽略所有传递过来的 HTML 标签,并将其视为用来替换原文本的文本。 +请强调 id 为target4的按钮的文本。 +请查看此链接来了解更多<i><em>的区别和用法。 +注意,<i>标签虽然传统上用来强调文本,但此后常用作图标的标签;<em>标签作为强调标签现在已被广泛接受。两者都可以应对本次挑战。 +
## Instructions -
+
+
## Tests @@ -18,15 +28,15 @@ localeTitle: 使用jQuery更改元素内的文本 ```yml tests: - - text: 通过添加HTML标记强调target4按钮中的文本。 + - text: 通过添加 HTML 标签强调target4按钮中的文本。 testString: assert.isTrue((/|\s*#target4\s*<\/em>|<\/i>/gi).test($("#target4").html())); - - text: 确保文本不变。 + - text: 确保文本不乱。 testString: assert($("#target4") && $("#target4").text().trim() === '#target4'); - - text: 不要改变任何其他文字。 + - text: 不改变其他任何文本内容。 testString: assert.isFalse((/|/gi).test($("h3").html())); - - text: 确保使用.html()而不是.text() 。 + - text: 确保使用.html()方法而不是.text()方法。 testString: assert(code.match(/\.html\(/g)); - - text: 确保使用jQuery选择button id="target4" 。 + - text: "确保用 jQuery 选取button id='target4'。" testString: assert(code.match(/\$\(\s*?(\"|\')#target4(\"|\')\s*?\)\.html\(/)); ``` @@ -46,7 +56,7 @@ tests: }); - +

jQuery Playground

@@ -69,7 +79,6 @@ tests:
- ``` @@ -81,8 +90,35 @@ tests: ## Solution
-```js -// solution required +```html + + +
+

jQuery Playground

+
+
+

#left-well

+
+ + + +
+
+
+

#right-well

+
+ + + +
+
+
+
``` -/section> +
diff --git a/curriculum/challenges/chinese/03-front-end-libraries/jquery/change-the-css-of-an-element-using-jquery.chinese.md b/curriculum/challenges/chinese/03-front-end-libraries/jquery/change-the-css-of-an-element-using-jquery.chinese.md index 95e8d37ecf..bfbe5097f9 100644 --- a/curriculum/challenges/chinese/03-front-end-libraries/jquery/change-the-css-of-an-element-using-jquery.chinese.md +++ b/curriculum/challenges/chinese/03-front-end-libraries/jquery/change-the-css-of-an-element-using-jquery.chinese.md @@ -4,15 +4,24 @@ title: Change the CSS of an Element Using jQuery required: - link: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.0/animate.css' challengeType: 6 -videoUrl: '' -localeTitle: 使用jQuery更改元素的CSS +forumTopicId: 16776 +localeTitle: 使用 jQuery 更改元素的 CSS --- ## Description -
我们也可以使用jQuery直接更改HTML元素的CSS。 jQuery有一个名为.css()的函数,允许您更改元素的CSS。以下是我们将其颜色更改为蓝色的方法: $("#target1").css("color", "blue");这与普通的CSS声明略有不同,因为CSS属性及其值在引号中,并用逗号而不是冒号分隔。删除jQuery选择器,留下一个空的document ready function 。选择target1并将其颜色更改为红色。
+
+我们也能用 jQuery 直接改变 HTML 标签的 CSS。 +jQuery 有一个.css()方法,其能改变标签的 CSS。 +下面的代码效果是把颜色变蓝: +$("#target1").css("color", "blue"); +这与通常的 CSS 声明略有不同,因为这个 CSS 属性和它的值在英文引号里,并且它们用逗号而不是冒号间隔开。 +删除你的jQuery选择器,并留下空的document ready function。 +请选择target1并将其颜色变为红色(red)。 +
## Instructions -
+
+
## Tests @@ -20,9 +29,9 @@ localeTitle: 使用jQuery更改元素的CSS ```yml tests: - - text: 您的target1元素应该有红色文本。 + - text: target1标签应该有红色文本。 testString: assert($("#target1").css("color") === 'rgb(255, 0, 0)'); - - text: 只使用jQuery将这些类添加到元素中。 + - text: 仅用 jQuery 给标签添加类。 testString: assert(!code.match(/class.*animated/g)); ``` @@ -45,7 +54,7 @@ tests: }); - +

jQuery Playground

@@ -68,7 +77,6 @@ tests:
- ``` @@ -80,8 +88,39 @@ tests: ## Solution
-```js -// solution required +```html + + + +
+

jQuery Playground

+
+
+

#left-well

+
+ + + +
+
+
+

#right-well

+
+ + + +
+
+
+
``` -/section> +
diff --git a/curriculum/challenges/chinese/03-front-end-libraries/jquery/clone-an-element-using-jquery.chinese.md b/curriculum/challenges/chinese/03-front-end-libraries/jquery/clone-an-element-using-jquery.chinese.md index 356102d817..56ad631ae8 100644 --- a/curriculum/challenges/chinese/03-front-end-libraries/jquery/clone-an-element-using-jquery.chinese.md +++ b/curriculum/challenges/chinese/03-front-end-libraries/jquery/clone-an-element-using-jquery.chinese.md @@ -2,15 +2,23 @@ id: bad87fee1348bd9aed508826 title: Clone an Element Using jQuery challengeType: 6 -videoUrl: '' -localeTitle: 使用jQuery克隆元素 +forumTopicId: 16780 +localeTitle: 使用 jQuery 克隆元素 --- ## Description -
除了移动元素,您还可以将它们从一个地方复制到另一个地方。 jQuery有一个名为clone()的函数,它可以复制一个元素。例如,如果我们想将target2从我们的left-well复制到right-well ,我们将使用: $("#target2").clone().appendTo("#right-well");您是否注意到这涉及将两个jQuery函数粘在一起?这称为function chaining ,它是使用jQuery完成任务的便捷方式。克隆你的target5元素并将其附加到你的left-well
+
+除了移动标签,也可以把元素从一个地方复制到另一地方。 +jQuery 有一个clone()方法,可以复制标签。 +例如,如果想把target2left-well复制到right-well,可以设置如下: +$("#target2").clone().appendTo("#right-well"); +你是否注意到这两个 jQuery 方法连在一起了吗?这被称为链式调用(function chaining),是一种用 jQuery 实现效果的简便方法。 +克隆target5标签并附加到left-well。 +
## Instructions -
+
+
## Tests @@ -18,11 +26,11 @@ localeTitle: 使用jQuery克隆元素 ```yml tests: - - text: 你的target5元素应该在你的right-well 。 + - text: target5标签应该在right-well内。 testString: assert($("#right-well").children("#target5").length > 0); - - text: 您的target5元素的副本也应该在您的left-well 。 + - text: 克隆target5标签并放在left-well内。 testString: assert($("#left-well").children("#target5").length > 0); - - text: 只使用jQuery来移动这些元素。 + - text: 仅用 jQuery 移动这些标签。 testString: assert(!code.match(/class.*animated/g)); ``` @@ -45,6 +53,51 @@ tests: }); + + +
+

jQuery Playground

+
+
+

#left-well

+
+ + + +
+
+
+

#right-well

+
+ + + +
+
+
+
+``` + + + + + +
+ +## Solution +
+ +```html + +
@@ -68,20 +121,6 @@ tests:
- ``` - - - -
- -## Solution -
- -```js -// solution required -``` - -/section> diff --git a/curriculum/challenges/chinese/03-front-end-libraries/jquery/delete-your-jquery-functions.chinese.md b/curriculum/challenges/chinese/03-front-end-libraries/jquery/delete-your-jquery-functions.chinese.md index 7880351570..a89b22d65e 100644 --- a/curriculum/challenges/chinese/03-front-end-libraries/jquery/delete-your-jquery-functions.chinese.md +++ b/curriculum/challenges/chinese/03-front-end-libraries/jquery/delete-your-jquery-functions.chinese.md @@ -4,15 +4,19 @@ title: Delete Your jQuery Functions required: - link: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.0/animate.css' challengeType: 6 -videoUrl: '' -localeTitle: 删除您的jQuery函数 +forumTopicId: 17561 +localeTitle: 删除 jQuery 函数 --- ## Description -
这些动画起初很酷,但现在它们让人分心。从document ready function删除所有这三个jQuery函数,但保留document ready function本身。
+
+这些动画开始看起来很酷,但是有时可能会让用户分心。 +请删除document ready function内的三个 jQuery 函数,但保留document ready function本身。 +
## Instructions -
+
+
## Tests @@ -20,15 +24,15 @@ localeTitle: 删除您的jQuery函数 ```yml tests: - - text: 从document ready function删除所有三个jQuery document ready function 。 + - text: 删除document ready function中的三个 jQuery 函数。 testString: assert(code.match(/\{\s*\}\);/g)); - - text: 保持script元素不变。 + - text: 保持script标签不变。 testString: assert(code.match(/ + + +
+

jQuery Playground

+
+
+

#left-well

+
+ + + +
+
+
+

#right-well

+
+ + + +
+
+
+
+``` + + + + + +
+ +## Solution +
+ +```html + +
@@ -73,20 +118,6 @@ tests:
- ``` - - - -
- -## Solution -
- -```js -// solution required -``` - -/section> diff --git a/curriculum/challenges/chinese/03-front-end-libraries/jquery/disable-an-element-using-jquery.chinese.md b/curriculum/challenges/chinese/03-front-end-libraries/jquery/disable-an-element-using-jquery.chinese.md index c61a80aca3..bb5ca60a60 100644 --- a/curriculum/challenges/chinese/03-front-end-libraries/jquery/disable-an-element-using-jquery.chinese.md +++ b/curriculum/challenges/chinese/03-front-end-libraries/jquery/disable-an-element-using-jquery.chinese.md @@ -2,15 +2,23 @@ id: bad87fee1348bd9aed808826 title: Disable an Element Using jQuery challengeType: 6 -videoUrl: '' -localeTitle: 使用jQuery禁用元素 +forumTopicId: 17563 +localeTitle: 使用 jQuery 禁用元素 --- ## Description -
您还可以使用jQuery更改HTML元素的非CSS属性。例如,您可以禁用按钮。禁用按钮后,它将变为灰色,无法再单击。 jQuery有一个名为.prop()的函数,允许您调整元素的属性。以下是禁用所有按钮的方法: $("button").prop("disabled", true);仅禁用target1按钮。
+
+你还能用 jQuery 改变 HTML 标签的非 CSS 属性,例如:能禁用按钮。 +当你禁用按钮时,它将变成灰色并无法点击。 +jQuery 有一个.prop()方法,你可以用其调整标签的属性。 +下面的代码效果是禁用所有的按钮: +$("button").prop("disabled", true); +请仅禁用target1按钮。 +
## Instructions -
+
+
## Tests @@ -20,9 +28,9 @@ localeTitle: 使用jQuery禁用元素 tests: - text: 禁用target1按钮。 testString: assert($("#target1") && $("#target1").prop("disabled") && code.match(/["']disabled["'],( true|true)/g)); - - text: 不要禁用任何其他按钮。 + - text: 不禁用其他的按钮。 testString: assert($("#target2") && !$("#target2").prop("disabled")); - - text: 只使用jQuery将这些类添加到元素中。 + - text: 仅用 jQuery 给标签添加类。 testString: assert(!code.match(/disabled[^<]*>/g)); ``` @@ -42,6 +50,49 @@ tests: }); + + +
+

jQuery Playground

+
+
+

#left-well

+
+ + + +
+
+
+

#right-well

+
+ + + +
+
+
+
+``` + + + + + +
+ +## Solution +
+ +```html + +
@@ -65,20 +116,6 @@ tests:
- ``` - - - -
- -## Solution -
- -```js -// solution required -``` - -/section> diff --git a/curriculum/challenges/chinese/03-front-end-libraries/jquery/learn-how-script-tags-and-document-ready-work.chinese.md b/curriculum/challenges/chinese/03-front-end-libraries/jquery/learn-how-script-tags-and-document-ready-work.chinese.md index 701721be36..3031e4eecf 100644 --- a/curriculum/challenges/chinese/03-front-end-libraries/jquery/learn-how-script-tags-and-document-ready-work.chinese.md +++ b/curriculum/challenges/chinese/03-front-end-libraries/jquery/learn-how-script-tags-and-document-ready-work.chinese.md @@ -2,15 +2,24 @@ id: bad87fee1348bd9acdd08826 title: Learn How Script Tags and Document Ready Work challengeType: 6 -videoUrl: '' -localeTitle: 了解脚本标签和文档准备工作的方式 +forumTopicId: 18224 +localeTitle: 了解 script 和 document.ready 是如何工作的 --- ## Description -
现在我们已经准备好学习jQuery,这是有史以来最流行的JavaScript工具。在我们开始使用jQuery之前,我们需要在HTML中添加一些内容。首先,在页面顶部添加一个script元素。请务必在以下行中关闭它。您的浏览器将在script元素中运行任何JavaScript,包括jQuery。在您的script元素中,添加以下代码: $(document).ready(function() {到您的script 。然后在以下行(仍然在您的script元素中)关闭它: });我们稍后会详细了解这些functions 。重要的是要知道,在浏览器加载页面后,您放入此function代码将立即运行。这很重要,因为没有您的document ready function ,您的代码可能会在HTML呈现之前运行,这会导致错误。
+
+现在我们已经准备好学习有史以来最受欢迎的 JavaScript 框架——jQuery 了。 +在使用 jQuery 之前,我们需要在 HTML 页面中添加一些东西。 +首先,在页面顶部添加script标签,记得在后面为script标签添加结束标签。 +浏览器在script标签中运行所有的 JavaScript 脚本包括 jQuery。 +在script标签中添加代码$(document).ready(function() {。然后在后面(仍在该script标签内)用});闭合它。 +稍后我们将详细介绍functions,现在需要知道的是,只要浏览器加载页面,function中放入的代码就会运行。 +有一点很重要,如果没有document ready function,你的代码将在 HTML 页面呈现之前运行,这将导致错误。 +
## Instructions -
+
+
## Tests @@ -18,11 +27,11 @@ localeTitle: 了解脚本标签和文档准备工作的方式 ```yml tests: - - text: 创建一个script元素,确保它有效并具有结束标记。 + - text: 创建一个script标签,确保其有效并具有闭合标签。 testString: 'assert(code.match(/<\/script\s*>/g) && code.match(//g) && code.match(/<\/script\s*>/g).length === code.match(//g).length);' - - text: '您应该将$(document).ready (function() {script元素的开头。' + - text: 在script的开头添加$(document).ready(function() {。 testString: 'assert(code.match(/\$\s*?\(\s*?document\s*?\)\.ready\s*?\(\s*?function\s*?\(\s*?\)\s*?\{/g));' - - text: '关闭$(document).ready (function() { function with });' + - text: 用});闭合$(document).ready(function() {函数。 testString: 'assert(code.match(/\n*?\s*?\}\s*?\);/g));' ``` @@ -35,6 +44,45 @@ tests:
```html + + +
+

jQuery Playground

+
+
+

#left-well

+
+ + + +
+
+
+

#right-well

+
+ + + +
+
+
+
+``` + +
+ + + +
+ +## Solution +
+ +```html +
@@ -58,20 +106,6 @@ tests:
- ``` - - - -
- -## Solution -
- -```js -// solution required -``` - -/section> diff --git a/curriculum/challenges/chinese/03-front-end-libraries/jquery/remove-an-element-using-jquery.chinese.md b/curriculum/challenges/chinese/03-front-end-libraries/jquery/remove-an-element-using-jquery.chinese.md index 6e79e5b12a..93f6de0199 100644 --- a/curriculum/challenges/chinese/03-front-end-libraries/jquery/remove-an-element-using-jquery.chinese.md +++ b/curriculum/challenges/chinese/03-front-end-libraries/jquery/remove-an-element-using-jquery.chinese.md @@ -2,15 +2,20 @@ id: bad87fee1348bd9aed708826 title: Remove an Element Using jQuery challengeType: 6 -videoUrl: '' -localeTitle: 使用jQuery删除元素 +forumTopicId: 18262 +localeTitle: 使用 jQuery 删除元素 --- ## Description -
现在让我们使用jQuery从页面中删除HTML元素。 jQuery有一个名为.remove()的函数,它将完全删除HTML元素。使用.remove()函数从页面中删除元素target4
+
+现在学习用 jQuery 从页面移除 HTML 标签。 +jQuery 有一个.remove()方法,能完全移除 HTML 标签。 +请用.remove()方法从页面移除target4标签。 +
## Instructions -
+
+
## Tests @@ -18,9 +23,9 @@ localeTitle: 使用jQuery删除元素 ```yml tests: - - text: 使用jQuery从页面中删除target4元素。 + - text: 用 jQuery 从页面中移除target4标签。 testString: assert($("#target4").length === 0 && code.match(/\$\(["']#target4["']\).remove\(\)/g)); - - text: 仅使用jQuery删除此元素。 + - text: 仅用 jQuery 移除该标签。 testString: assert(code.match(/id="target4/g) && !code.match(//g) && $("#right-well").length > 0); ``` @@ -41,6 +46,49 @@ tests: }); + + +
+

jQuery Playground

+
+
+

#left-well

+
+ + + +
+
+
+

#right-well

+
+ + + +
+
+
+
+``` + + + + + +
+ +## Solution +
+ +```html + +
@@ -64,20 +112,6 @@ tests:
- ``` - - - -
- -## Solution -
- -```js -// solution required -``` - -/section> diff --git a/curriculum/challenges/chinese/03-front-end-libraries/jquery/remove-classes-from-an-element-with-jquery.chinese.md b/curriculum/challenges/chinese/03-front-end-libraries/jquery/remove-classes-from-an-element-with-jquery.chinese.md index ca8a25df8b..fd7660c4d0 100644 --- a/curriculum/challenges/chinese/03-front-end-libraries/jquery/remove-classes-from-an-element-with-jquery.chinese.md +++ b/curriculum/challenges/chinese/03-front-end-libraries/jquery/remove-classes-from-an-element-with-jquery.chinese.md @@ -4,15 +4,21 @@ title: Remove Classes from an Element with jQuery required: - link: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.0/animate.css' challengeType: 6 -videoUrl: '' -localeTitle: 使用jQuery从元素中删除类 +forumTopicId: 18264 +localeTitle: 使用 jQuery 从元素中移除 class --- ## Description -
以同样的方式,你可以添加类与jQuery的元素addClass()函数,你可以用jQuery的删除它们removeClass()函数。以下是为特定按钮执行此操作的方法: $("#target2").removeClass("btn-default");让我们从所有button元素中删除btn-default类。
+
+和用 jQuery 的addClass()方法给标签添加类一样,也可以利用 jQuery 的removeClass()方法移除他们。 +下面的代码效果是为特定的按钮执行上面的操作: +$("#target2").removeClass("btn-default"); +请把所有button标签的btn-default类移除。 +
## Instructions -
+
+
## Tests @@ -20,11 +26,11 @@ localeTitle: 使用jQuery从元素中删除类 ```yml tests: - - text: 从所有button元素中删除btn-default类。 + - text: 移除所有的button标签的btn-default属性。 testString: assert($(".btn-default").length === 0); - - text: 仅使用jQuery从元素中删除此类。 + - text: 仅用 jQuery 从标签中移除类。 testString: assert(code.match(/btn btn-default/g)); - - text: 只删除btn-default类。 + - text: 仅移除btn-default类。 testString: assert(code.match(/\.[\v\s]*removeClass[\s\v]*\([\s\v]*('|")\s*btn-default\s*('|")[\s\v]*\)/gm)); ``` @@ -46,6 +52,50 @@ tests: }); + + +
+

jQuery Playground

+
+
+

#left-well

+
+ + + +
+
+
+

#right-well

+
+ + + +
+
+
+
+``` + + + + + +
+ +## Solution +
+ +```html + +
@@ -69,20 +119,6 @@ tests:
- ``` - - - -
- -## Solution -
- -```js -// solution required -``` - -/section> diff --git a/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-a-specific-child-of-an-element-using-jquery.chinese.md b/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-a-specific-child-of-an-element-using-jquery.chinese.md index 256e317cba..e1b370f31f 100644 --- a/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-a-specific-child-of-an-element-using-jquery.chinese.md +++ b/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-a-specific-child-of-an-element-using-jquery.chinese.md @@ -4,15 +4,23 @@ title: Target a Specific Child of an Element Using jQuery required: - link: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.0/animate.css' challengeType: 6 -videoUrl: '' -localeTitle: 使用jQuery定位元素的特定子元素 +forumTopicId: 18315 +localeTitle: 使用 jQuery 选择元素的特定子元素 --- ## Description -
您已经了解了为什么id属性对于使用jQuery选择器进行定位非常方便。但是你不会总是有这么整洁的ids。幸运的是,jQuery还有一些其他技巧可用于定位正确的元素。 jQuery使用CSS选择器来定位元素。 target:nth-child(n) CSS选择器允许您选择具有目标类或元素类型的所有第n个元素。以下是如何给每个井中的第三个元素提供反弹类: $(".target:nth-child(3)").addClass("animated bounce");让每个井元素中的第二个孩子反弹。您必须选择具有target类的元素子项。
+
+你已经看到了为什么 id 属性对于 jQuery 选择器选取标签非常方便,但这并不适用于所有情景。 +幸运的是,jQuery 有一些其他的方法可以选取正确的标签。 +jQuery 可以用CSS 选择器(CSS Selectors)选取标签。target:nth-child(n)CSS 选择器可以选取所有的第 n 个标签并设置目标属性和目标样式。 +下面的代码展示了给每个区域(well)的第 3 个标签设置bounce类: +$(".target:nth-child(3)").addClass("animated bounce"); +请给每个区域(well)的第 2 个标签设置bounce类,必须用target类选取标签。 +
## Instructions -
+
+
## Tests @@ -20,13 +28,13 @@ localeTitle: 使用jQuery定位元素的特定子元素 ```yml tests: - - text: target元素中的第二个元素应该反弹。 + - text: target标签中的第二个标签应该有弹性的动画效果。 testString: assert($(".target:nth-child(2)").hasClass("animated") && $(".target:nth-child(2)").hasClass("bounce")); - - text: 只有两个元素应该反弹。 + - text: 应该仅两个标签有弹性的动画效果。 testString: assert($(".animated.bounce").length === 2); - - text: '您应该使用:nth-child()选择器来修改这些元素。' + - text: 应该用:nth-child()选择器修改这些标签。 testString: assert(code.match(/\:nth-child\(/g)); - - text: 只使用jQuery将这些类添加到元素中。 + - text: 仅用 jQuery 给标签添加类。 testString: assert(code.match(/\$\(".target:nth-child\(2\)"\)/g) || code.match(/\$\('.target:nth-child\(2\)'\)/g) || code.match(/\$\(".target"\).filter\(":nth-child\(2\)"\)/g) || code.match(/\$\('.target'\).filter\(':nth-child\(2\)'\)/g)); ``` @@ -52,6 +60,54 @@ tests: }); + + +
+

jQuery Playground

+
+
+

#left-well

+
+ + + +
+
+
+

#right-well

+
+ + + +
+
+
+
+``` + + + + + +
+ +## Solution +
+ +```html + +
@@ -75,20 +131,6 @@ tests:
- ``` - - - -
- -## Solution -
- -```js -// solution required -``` - -/section> diff --git a/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-elements-by-class-using-jquery.chinese.md b/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-elements-by-class-using-jquery.chinese.md index 9680f9cee5..6080b1e38f 100644 --- a/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-elements-by-class-using-jquery.chinese.md +++ b/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-elements-by-class-using-jquery.chinese.md @@ -4,15 +4,24 @@ title: Target Elements by Class Using jQuery required: - link: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.0/animate.css' challengeType: 6 -videoUrl: '' -localeTitle: 使用jQuery按类目标元素 +forumTopicId: 18316 +localeTitle: 使用 jQuery 配合 class 选择器选择元素 --- ## Description -
您看到我们如何使所有button元素反弹?我们用$("button")选择它们,然后我们用.addClass("animated bounce");为它们添加了一些CSS类.addClass("animated bounce"); 。您刚刚使用了jQuery的.addClass()函数,它允许您向元素添加类。首先,让我们使用$(".well")选择器将你的div元素与类well对准。请注意,就像CSS声明一样,您键入一个.在课堂名称之前。然后使用jQuery的.addClass()函数中添加类animatedshake 。例如,您可以通过将以下内容添加到document ready function来创建具有类text-primary shake的所有元素: $(".text-primary").addClass("animated shake");
+
+我们如何使所有的button标签有弹性的动画效果?我们用$("button")选取所有的button标签,并用.addClass("animated bounce");给其添加一些 CSS 属性。 +jQuery 的.addClass()方法用来给标签添加类。 +首先,我们使用$(".well")选取类为welldiv标签。 +值得注意的是,和 CSS 声明一样,在类名前需要添加.。 +然后,用 jQuery 的.addClass()方法添加animatedshake类。 +例如,在document ready function中添加下面的代码,能使所有类为text-primary的标签抖动: +$(".text-primary").addClass("animated shake"); +
## Instructions -
+
+
## Tests @@ -20,9 +29,9 @@ localeTitle: 使用jQuery按类目标元素 ```yml tests: - - text: 使用jQuery addClass()函数为类赋予animated并使用类well shake所有元素。 + - text: 用 jQuery 的addClass()方法给所有类为well的标签添加animatedshake类。 testString: assert($(".well").hasClass("animated") && $(".well").hasClass("shake")); - - text: 只使用jQuery将这些类添加到元素中。 + - text: 仅用 jQuery 给标签添加类。 testString: assert(!code.match(/class\.\*animated/g)); ``` @@ -41,6 +50,48 @@ tests: }); + + +
+

jQuery Playground

+
+
+

#left-well

+
+ + + +
+
+
+

#right-well

+
+ + + +
+
+
+
+``` + + + + + +
+ +## Solution +
+ +```html + +
@@ -64,20 +115,6 @@ tests:
- ``` - - - -
- -## Solution -
- -```js -// solution required -``` - -/section> diff --git a/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-elements-by-id-using-jquery.chinese.md b/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-elements-by-id-using-jquery.chinese.md index 0ded01890e..e7dd31c314 100644 --- a/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-elements-by-id-using-jquery.chinese.md +++ b/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-elements-by-id-using-jquery.chinese.md @@ -4,15 +4,23 @@ title: Target Elements by id Using jQuery required: - link: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.0/animate.css' challengeType: 6 -videoUrl: '' -localeTitle: id的目标元素使用jQuery +forumTopicId: 18317 +localeTitle: 使用 jQuery 配合 id 选择器选择元素 --- ## Description -
您还可以通过其id属性来定位元素。首先使用$("#target3")选择器将您的button元素与id target3 $("#target3") 。请注意,就像CSS声明一样,您在id的名称前键入# 。然后使用jQuery的.addClass()函数添加animated类和fadeOut 。以下是如何使用id target6淡出的button元素: $("#target6").addClass("animated fadeOut")
+
+你也能通过 id 属性选取标签。 +首先,用$("#target3")选择器选取 id 为target3button标签。 +注意,和 CSS 属性一样,在 id 名前需要添加#。 +然后,用 jQuery 的.addClass()方法添加animatedfadeOut类。 +下面的代码的效果是使 id 为target6button标签淡出: +$("#target6").addClass("animated fadeOut"). +
## Instructions -
+
+
## Tests @@ -20,11 +28,11 @@ localeTitle: id的目标元素使用jQuery ```yml tests: - - text: 选择idtarget3button元素,并使用jQuery addClass()函数为它提供animated类。 + - text: 用 jQuery 的addClass()方法给idtarget3button标签添加animated类。 testString: assert($("#target3").hasClass("animated")); - - text: 使用id target3定位元素,并使用jQuery addClass()函数为其提供类fadeOut 。 + - text: 用 jQuery 的addClass()方法给idtarget3的标签的类添加fadeOut类。 testString: assert(($("#target3").hasClass("fadeOut") || $("#target3").hasClass("fadeout")) && code.match(/\$\(\s*.#target3.\s*\)/g)); - - text: 只使用jQuery将这些类添加到元素中。 + - text: 仅用 jQuery 给标签设置类。 testString: assert(!code.match(/class.*animated/g)); ``` @@ -45,6 +53,49 @@ tests: }); + + +
+

jQuery Playground

+
+
+

#left-well

+
+ + + +
+
+
+

#right-well

+
+ + + +
+
+
+
+``` + + + + + +
+ +## Solution +
+ +```html + +
@@ -68,20 +119,6 @@ tests:
- ``` - - - -
- -## Solution -
- -```js -// solution required -``` - -/section> diff --git a/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-even-elements-using-jquery.chinese.md b/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-even-elements-using-jquery.chinese.md index c6bb87c1b4..4d6e47b942 100644 --- a/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-even-elements-using-jquery.chinese.md +++ b/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-even-elements-using-jquery.chinese.md @@ -4,15 +4,22 @@ title: Target Even Elements Using jQuery required: - link: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.0/animate.css' challengeType: 6 -videoUrl: '' -localeTitle: 使用jQuery定位偶数元素 +forumTopicId: 18318 +localeTitle: 使用 jQuery 选择偶数元素 --- ## Description -
您还可以使用:odd:even选择器根据位置定位元素。请注意,jQuery是零索引的,这意味着选择中的第一个元素的位置为0.这可能有点令人困惑,因为反直觉地:odd选择第二个元素(位置1),第四个元素(位置3) , 等等。以下是如何使用类target定位所有奇数元素并给它们类: $(".target:odd").addClass("animated shake");尝试选择所有偶数target元素,并为它们提供animatedshake类。请记住, 甚至指的是基于零系统的元素的位置。
+
+你也可以用基于位置的:odd:even选择器选取标签。 +注意,jQuery 是零索引(zero-indexed)的,这意味着第 1 个标签的位置编号是0。这有点混乱和反常——:odd表示选择第 2 个标签(位置编号 1),第 4 个标签(位置编号 3)……等等,以此类推。 +下面的代码展示了选取所有的奇标签并设置类: +$(".target:odd").addClass("animated shake"); +请尝试选取所有target标签的偶标签并给他们设置animatedshake类。要考虑到偶(even)指的是标签位置编号基于0的系统。 +
## Instructions -
+
+
## Tests @@ -20,11 +27,11 @@ localeTitle: 使用jQuery定位偶数元素 ```yml tests: - - text: jQuery认为的所有target元素都应该动摇。 + - text: 所有的target标签应该抖动。 testString: assert($('.target:even').hasClass('animated') && $('.target:even').hasClass('shake')); - - text: '您应该使用:even选择器来修改这些元素。' + - text: 应该用:even选择器修改这些标签。 testString: assert(code.match(/\:even/g)); - - text: 只使用jQuery将这些类添加到元素中。 + - 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)); ``` @@ -52,6 +59,56 @@ tests: }); + + +
+

jQuery Playground

+
+
+

#left-well

+
+ + + +
+
+
+

#right-well

+
+ + + +
+
+
+
+``` + + + + + +
+ +## Solution +
+ +```html + +
@@ -75,20 +132,6 @@ tests:
- ``` - - - -
- -## Solution -
- -```js -// solution required -``` - -/section> diff --git a/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-html-elements-with-selectors-using-jquery.chinese.md b/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-html-elements-with-selectors-using-jquery.chinese.md index cc224f4d3b..0ea497c5e7 100644 --- a/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-html-elements-with-selectors-using-jquery.chinese.md +++ b/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-html-elements-with-selectors-using-jquery.chinese.md @@ -4,15 +4,23 @@ title: Target HTML Elements with Selectors Using jQuery required: - link: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.0/animate.css' challengeType: 6 -videoUrl: '' -localeTitle: 使用选择器使用jQuery定位HTML元素 +forumTopicId: 18319 +localeTitle: 使用 jQuery 配合元素选择器选择元素 --- ## 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元素。
+
+接下来我们学习document ready function。 +首先,我们完成第一个 jQuery 语句。所有的 jQuery 函数以$开头,这个符号通常被称为美元符号(dollar sign operator)bling。 +jQuery 通常选取并操作带有选择器(selector)的 HTML 标签。 +例如,如果要所有button有弹性的动画效果,只需在document ready function中添加如下代码即可: +$("button").addClass("animated bounce"); +请注意,为了能在编辑器里直接使用,我们已经为你在后台引入了 jQuery 库和 Animate.css 库。因此,你只需要通过 jQuery 给button元素添加bounce类就可以了。 +
## Instructions -
+
+
## Tests @@ -20,11 +28,11 @@ localeTitle: 使用选择器使用jQuery定位HTML元素 ```yml tests: - - text: 使用jQuery addClass()函数将类animatedbounce回到button元素。 + - text: 用 jQuery 的addClass()方法给button标签添加animatedbounce类。 testString: 'assert($("button").hasClass("animated") && $("button").hasClass("bounce"));' - - text: 只使用jQuery将这些颜色添加到元素中。 + - text: 仅用 jQuery 给标签添加颜色。 testString: 'assert(!code.match(/class.*animated/g));' - - text: 你的jQuery代码应该在$(document).ready();功能。 + - text: jQuery 代码应该放在$(document).ready();函数里。 testString: assert(code.match(/\$\(document\)\.ready\(function.*(\s|\n)*.*button.*.addClass.*\);/g)); ``` @@ -43,6 +51,47 @@ tests: }); + + +
+

jQuery Playground

+
+
+

#left-well

+
+ + + +
+
+
+

#right-well

+
+ + + +
+
+
+
+``` + + + + + +
+ +## Solution +
+ +```html + +
@@ -66,20 +115,6 @@ tests:
- ``` - - - -
- -## Solution -
- -```js -// solution required -``` - -/section> diff --git a/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-the-children-of-an-element-using-jquery.chinese.md b/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-the-children-of-an-element-using-jquery.chinese.md index ba5b98f31b..38c4ec946a 100644 --- a/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-the-children-of-an-element-using-jquery.chinese.md +++ b/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-the-children-of-an-element-using-jquery.chinese.md @@ -2,26 +2,33 @@ id: bad87fee1348bd9aed208826 title: Target the Children of an Element Using jQuery challengeType: 6 -videoUrl: '' -localeTitle: 使用jQuery定位元素的子元素 +forumTopicId: 18320 +localeTitle: 使用 jQuery 选择元素的子元素 --- ## Description -
当HTML元素放在另一个下面时,它们被称为该元素的children元素。例如,在与文本“#Target1时”,“#TARGET2”,和“#target3”这一挑战的按钮元件都是children的的<div class="well" id="left-well">元素。 jQuery有一个名为children()的函数,允许您访问您选择的元素的子元素。下面是一个示例,说明如何使用children()函数为left-well元素的子项设置blue$("#left-well").children().css("color", "blue")
+
+把 HTML 标签放到另一个级别的标签里,这些 HTML 标签被称为该标签的子标签(children element)。例如,本次挑战中文本为 "#target1"、"#target2" 和 "#target3" 的按钮都是<div class="well" id="left-well">标签的子标签。 +jQuery 有一个children()方法,可以访问被选取标签的子标签。 +下面的代码展示了用children()方法把left-well标签的子标签的颜色设置成蓝色(blue): +$("#left-well").children().css("color", "blue") +
## Instructions -
给你的right-well元素的所有孩子颜色为橙色。
+
+请把right-well标签的所有子标签颜色设置成橙色(orange)。 +
## Tests
```yml tests: - - text: '#right-well所有孩子都应该有橙色文字。' + - text: #right-well所有的子标签文本应该是橙色。 testString: assert($("#right-well").children().css("color") === 'rgb(255, 165, 0)'); - - text: 您应该使用children()函数来修改这些元素。 + - text: 应该用children()方法修改标签。 testString: assert(code.match(/\.children\(\)\.css/g)); - - text: 只使用jQuery将这些类添加到元素中。 + - text: 仅用 jQuery 给标签添加类。 testString: assert(code.match(/
/g)); ``` @@ -46,6 +53,53 @@ tests: }); + + +
+

jQuery Playground

+
+
+

#left-well

+
+ + + +
+
+
+

#right-well

+
+ + + +
+
+
+
+``` + +
+ + + +
+ +## Solution +
+ +```html + +
@@ -69,20 +123,7 @@ tests:
- ``` - - - -
-## Solution -
- -```js -// solution required -``` - -/section> diff --git a/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-the-parent-of-an-element-using-jquery.chinese.md b/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-the-parent-of-an-element-using-jquery.chinese.md index 2c25244f02..b1b59778b7 100644 --- a/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-the-parent-of-an-element-using-jquery.chinese.md +++ b/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-the-parent-of-an-element-using-jquery.chinese.md @@ -2,15 +2,23 @@ id: bad87fee1348bd9aed308826 title: Target the Parent of an Element Using jQuery challengeType: 6 -videoUrl: '' -localeTitle: 使用jQuery定位元素的父级 +forumTopicId: 18321 +localeTitle: 使用 jQuery 选择元素的父元素 --- ## Description -
每个HTML元素都有一个parent元素,它从中inherits属性。例如,您的jQuery Playground h3元素具有<div class="container-fluid">的父元素,它本身具有父body 。 jQuery有一个名为parent()的函数,允许您访问您选择的任何元素的父级。下面是一个如何使用parent()函数的例子,如果你想给left-well元素的父元素一个蓝色的背景颜色: $("#left-well").parent().css("background-color", "blue")#target1元素的父级#target1背景颜色为红色。
+
+每个 HTML 标签都默认继承(inherits)父标签(parent element)的 CSS 属性。 +例如,h3标签jQuery Playground的父标签是<div class="container-fluid"><div class="container-fluid">的父标签是body。 +jQuery 有一个parent()方法,可以访问被选取标签的父标签。 +下面的代码展示了使用parent()方法把left-well标签的父标签背景色设置成蓝色(blue)的方式: +$("#left-well").parent().css("background-color", "blue") +请把#target1标签的父标签背景色设置成红色(red)。 +
## Instructions -
+
+
## Tests @@ -18,13 +26,13 @@ localeTitle: 使用jQuery定位元素的父级 ```yml tests: - - text: 你的left-well元素应该有红色背景。 + - text: left-well标签应该有红色的背景。 testString: assert($("#left-well").css("background-color") === 'red' || $("#left-well").css("background-color") === 'rgb(255, 0, 0)' || $("#left-well").css("background-color").toLowerCase() === '#ff0000' || $("#left-well").css("background-color").toLowerCase() === '#f00'); - - text: 您应该使用.parent()函数来修改此元素。 + - text: 应该用.parent()方法修改该标签。 testString: assert(code.match(/\.parent\s*\(\s*\)\s*\.css/g)); - - text: '应该在#target1元素上调用.parent()方法。' + - text: 应该在#target1标签上调用.parent()方法。 testString: assert(code.match(/\$\s*?\(\s*?(?:'|")\s*?#target1\s*?(?:'|")\s*?\)\s*?\.parent/gi)); - - text: 只使用jQuery将这些类添加到元素中。 + - text: 仅用 jQuery 给标签添加类。 testString: assert(code.match(/
/g)); ``` @@ -48,6 +56,54 @@ tests: }); + + + +
+

jQuery Playground

+
+
+

#left-well

+
+ + + +
+
+
+

#right-well

+
+ + + +
+
+
+
+ +``` + +
+ + + +
+ +## Solution +
+ +```html + + @@ -73,20 +129,7 @@ tests: - ``` - - - -
-## Solution -
- -```js -// solution required -``` - -/section> diff --git a/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-the-same-element-with-multiple-jquery-selectors.chinese.md b/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-the-same-element-with-multiple-jquery-selectors.chinese.md index 298f6377c9..6480b18f52 100644 --- a/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-the-same-element-with-multiple-jquery-selectors.chinese.md +++ b/curriculum/challenges/chinese/03-front-end-libraries/jquery/target-the-same-element-with-multiple-jquery-selectors.chinese.md @@ -4,15 +4,24 @@ title: Target the Same Element with Multiple jQuery Selectors required: - link: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.0/animate.css' challengeType: 6 -videoUrl: '' -localeTitle: 使用多个jQuery选择器定位相同的元素 +forumTopicId: 18322 +localeTitle: 用多个 jQuery 选择器选择同一个元素 --- ## Description -
现在你知道三种定位元素的方法:按类型: $("button") ,按类: $(".btn")和id $("#target1") 。虽然可以在单个.addClass()调用中添加多个类,但是让我们以三种不同的方式将它们添加到同一个元素中。使用.addClass() ,一次只向同一个元素添加一个类,有三种不同的方式:使用类型buttonanimated类添加到所有元素。使用类.btnshake类添加到所有按钮。将btn-primary类添加到id为#target1的按钮。 注意
您应该只定位一个元素,一次只添加一个类。总而言之,您的三个选择器最终会将三个类shakeanimatedbtn-primary#target1
+
+现在你知道三种选取标签的方法:用标签选择器,如$("button");用类选择器,$(".btn")以及用 id 选择器,$("#target1")。 +虽然可以在单个.addClass()内添加多个类,但是我们可以用三种不同的方式给一种标签添加类。 +以三种不同的方式用.addClass()方法每次只给一种标签添加一个类: +给所有的button标签添加animated类。 +给所有类为.btnbutton标签添加shake类。 +给所有 id 为#target1button标签添加btn-primary类。 +注意:
虽然三个选择器最终给 id 为#target1button标签添加shakeanimatedbtn-primary等三个类,但是你需要用且仅用三种不同的选择器给三种标签各添加一个类(译者注:所谓的“一种标签”是指他们有某种共同的特点,如包含同一个 class)。 +
## Instructions -
+
+
## Tests @@ -20,17 +29,17 @@ localeTitle: 使用多个jQuery选择器定位相同的元素 ```yml tests: - - text: 使用$("button")选择器。 + - text: "用$('button')选择标签。" testString: assert(code.match(/\$\s*?\(\s*?(?:'|")\s*?button\s*?(?:'|")/gi)); - - text: 使用$(".btn")选择器。 + - text: "用$('.btn')选择标签。" testString: assert(code.match(/\$\s*?\(\s*?(?:'|")\s*?\.btn\s*?(?:'|")/gi)); - - text: '使用$("#target1")选择器。' + - text: "用$('#target1')选择标签。" testString: assert(code.match(/\$\s*?\(\s*?(?:'|")\s*?#target1\s*?(?:'|")/gi)); - - text: 只为每个三个选择器添加一个类。 + - text: 三个选择器每个只添加一个类。 testString: assert(code.match(/addClass/g) && code.match(/addClass\s*?\(\s*?('|")\s*?[\w-]+\s*?\1\s*?\)/g).length > 2); - - text: '你的#target1元素应该有animated类, shakebtn-primary 。' + - text: #target1标签应具有animatedshakebtn-primary三个类。 testString: assert($('#target1').hasClass('animated') && $('#target1').hasClass('shake') && $('#target1').hasClass('btn-primary')); - - text: 只使用jQuery将这些类添加到元素中。 + - text: 仅用 jQuery 给标签添加类。 testString: assert(!code.match(/class.*animated/g)); ``` @@ -49,6 +58,49 @@ tests: }); + + +
+

jQuery Playground

+
+
+

#left-well

+
+ + + +
+
+
+

#right-well

+
+ + + +
+
+
+
+``` + + + + + +
+ +## Solution +
+ +```html + +
@@ -72,20 +124,7 @@ tests:
- ``` - - - -
-## Solution -
- -```js -// solution required -``` - -/section> diff --git a/curriculum/challenges/chinese/03-front-end-libraries/jquery/use-appendto-to-move-elements-with-jquery.chinese.md b/curriculum/challenges/chinese/03-front-end-libraries/jquery/use-appendto-to-move-elements-with-jquery.chinese.md index 8984daf817..68e1c432ef 100644 --- a/curriculum/challenges/chinese/03-front-end-libraries/jquery/use-appendto-to-move-elements-with-jquery.chinese.md +++ b/curriculum/challenges/chinese/03-front-end-libraries/jquery/use-appendto-to-move-elements-with-jquery.chinese.md @@ -2,15 +2,22 @@ id: bad87fee1348bd9aed608826 title: Use appendTo to Move Elements with jQuery challengeType: 6 -videoUrl: '' -localeTitle: 使用appendTo使用jQuery移动元素 +forumTopicId: 18340 +localeTitle: 使用 jQuery 的 appendTo 方法移动元素 --- ## Description -
现在让我们尝试将元素从一个div移动到另一个div 。 jQuery有一个名为appendTo()的函数,它允许您选择HTML元素并将它们附加到另一个元素。例如,如果我们想将target4从我们的右井移动到我们的左井,我们将使用: $("#target4").appendTo("#left-well");target2元素从left-wellright-well
+
+现在我们学习把标签从一个div移动到另一个div。 +jQuery 有一个appendTo()方法,可以选取 HTML 标签并将其添加到另一个标签里面。 +例如,如果要把target4从右框移到左框,可以设置如下: +$("#target4").appendTo("#left-well"); +请把target2标签从left-well移动到right-well。 +
## Instructions -
+
+
## Tests @@ -18,11 +25,11 @@ localeTitle: 使用appendTo使用jQuery移动元素 ```yml tests: - - text: 您的target2元素不应位于left-well 。 + - text: target2标签应该不在left-well内。 testString: assert($("#left-well").children("#target2").length === 0); - - text: 你的target2元素应该在你的right-well 。 + - text: target2标签应该在right-well内。 testString: assert($("#right-well").children("#target2").length > 0); - - text: 只使用jQuery来移动这些元素。 + - text: 仅用 jQuery 移动这些标签。 testString: assert(!code.match(/class.*animated/g)); ``` @@ -44,6 +51,50 @@ tests: }); + + +
+

jQuery Playground

+
+
+

#left-well

+
+ + + +
+
+
+

#right-well

+
+ + + +
+
+
+
+``` + + + + + +
+ +## Solution +
+ +```html + +
@@ -67,20 +118,7 @@ tests:
- ``` - - - -
-## Solution -
- -```js -// solution required -``` - -/section> diff --git a/curriculum/challenges/chinese/03-front-end-libraries/jquery/use-jquery-to-modify-the-entire-page.chinese.md b/curriculum/challenges/chinese/03-front-end-libraries/jquery/use-jquery-to-modify-the-entire-page.chinese.md index bfd3ad3ccc..1e12a860b6 100644 --- a/curriculum/challenges/chinese/03-front-end-libraries/jquery/use-jquery-to-modify-the-entire-page.chinese.md +++ b/curriculum/challenges/chinese/03-front-end-libraries/jquery/use-jquery-to-modify-the-entire-page.chinese.md @@ -4,15 +4,21 @@ title: Use jQuery to Modify the Entire Page required: - link: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.0/animate.css' challengeType: 6 -videoUrl: '' -localeTitle: 使用jQuery修改整个页面 +forumTopicId: 18361 +localeTitle: 使用 jQuery 修改整个页面 --- ## Description -
我们玩完了jQuery游乐场。让我们把它撕下来! jQuery也可以定位body元素。以下是我们如何使整个身体淡出: $("body").addClass("animated fadeOut");但是,让我们做一些更具戏剧性的事情。将animated类和hinge添加到您的body元素中。
+
+jQuery 的学习到这里就告一段落了,现在我们来试一试让元素消失的特效。 +jQuery 也能选取body标签。 +后面的代码效果是使整个body标签淡出: $("body").addClass("animated fadeOut"); +接下来我们做一些更有戏剧性的事:给body标签添加animatedhinge类。 +
## Instructions -
+
+
## Tests @@ -20,7 +26,7 @@ localeTitle: 使用jQuery修改整个页面 ```yml tests: - - text: 将animated类和hinge添加到您的body元素中。 + - text: 给body标签添加animatedhinge类。 testString: assert($('body').hasClass('animated') && $('body').hasClass('hinge')); ``` @@ -49,6 +55,57 @@ tests: }); + + +
+

jQuery Playground

+
+
+

#left-well

+
+ + + +
+
+
+

#right-well

+
+ + + +
+
+
+
+``` + + + + + +
+ +## Solution +
+ +```html + +
@@ -72,20 +129,7 @@ tests:
- ``` - - - -
-## Solution -
- -```js -// solution required -``` - -/section>