freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/basic-html-and-html5/comment-out-html.md

1.0 KiB

id title challengeType videoUrl forumTopicId
bad87fee1348bd9aedf08804 给 HTML 添加注释 0 https://scrimba.com/p/pVMPUv/cGyGbca 16782

--description--

记住:注释的开始标记是<!--,结束标记是-->

现在你需要在h2元素前终止注释。

--instructions--

任务:注释掉h1元素和p元素,保留h2元素。

--hints--

注释掉h1元素,这样它就从网页上消失了。

assert($('h1').length === 0);

h2元素保持原样,这样网页上还能看到它。

assert($('h2').length > 0);

注释掉p元素,这样它就从网页上消失了。

assert($('p').length === 0);

确保每一个注释都以-->结尾。

assert(code.match(/[^fc]-->/g).length > 1);

不要更改h1元素、h2 元素、p元素的顺序。

assert(
  code.match(/<([a-z0-9]){1,2}>/g)[0] === '<h1>' &&
    code.match(/<([a-z0-9]){1,2}>/g)[1] === '<h2>' &&
    code.match(/<([a-z0-9]){1,2}>/g)[2] === '<p>'
);

--solutions--