Files
freeCodeCamp/curriculum/challenges/chinese/04-data-visualization/data-visualization-with-d3/select-a-group-of-elements-with-d3.chinese.md
Kristofer Koishigawa b3213fc892 fix(i18n): chinese test suite (#38220)
* 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
2020-03-03 18:49:47 +05:30

1.6 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
587d7fa6367417b2b2512bc3 Select a Group of Elements with D3 6 使用D3选择一组元素

Description

D3还有selectAll()方法来选择一组元素。它返回文档中与输入字符串匹配的所有项目的HTML节点数组。这是一个选择文档中所有锚标记的示例 const anchors = d3.selectAll("a");select()方法一样, selectAll()支持方法链接,您可以将其与其他方法一起使用。

Instructions

选择文档中的所有li标签,并通过链接.text()方法将其文本更改为“list item”。

Tests

tests:
  - text: 页面上应该有3个<code>li</code>元素每个元素中的文本应该是“list item”。大写和间距应完全匹配。
    testString: assert($('li').text().match(/list item/g).length == 3);
  - text: 您的代码应该访问<code>d3</code>对象。
    testString: assert(code.match(/d3/g));
  - text: 您的代码应该使用<code>selectAll</code>方法。
    testString: assert(code.match(/\.selectAll/g));

Challenge Seed

<body>
  <ul>
    <li>Example</li>
    <li>Example</li>
    <li>Example</li>
  </ul>
  <script>
    // Add your code below this line



    // Add your code above this line
  </script>
</body>

Solution

// solution required