* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
1.4 KiB
1.4 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
587d7fa6367417b2b2512bc3 | 用 D3 选择一组元素 | 6 | 301490 | select-a-group-of-elements-with-d3 |
--description--
selectAll()
方法选择一组元素。它以 HTML 节点数组的形式返回该文本中所有匹配所输入字符串的对象。以下是一个选择文本中所有锚标签的例子:
const anchors = d3.selectAll("a");
像 select()
方法一样,selectAll()
也支持链式调用,你可以在它之后调用其他方法。
--instructions--
选择所有的 li
标签,通过 .text()
方法将它的文本改为 "list item" 。
--hints--
页面上应该有 3 个 li
元素,每个元素的文本内容应为 'list item'。大小写和空格必须一致。
assert(
$('li')
.text()
.match(/list item/g).length == 3
);
你应该能访问 d3
的对象。
assert(code.match(/d3/g));
你应该使用 selectAll
方法。
assert(code.match(/\.selectAll/g));
--seed--
--seed-contents--
<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>
--solutions--
<body>
<ul>
<li>Example</li>
<li>Example</li>
<li>Example</li>
</ul>
<script>
d3.selectAll("li")
.text("list item")
</script>
</body>