2.0 KiB
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId
id title challengeType videoUrl forumTopicId
bad87fee1348bd9aedf08828 创建一个有序列表 0 https://scrimba.com/p/pVMPUv/cQ3B8TM 16824

--description--

HTML 有一个特定的元素用于创建有序列表ordered lists缩写 ol

有序列表以<ol>开始,中间包含一个或多个<li>元素,最后以</ol>结尾。

例如:

<ol>
  <li>加菲猫</li>
  <li>哆啦A梦</li>
</ol>

将会创建一个包含加菲猫和哆啦A梦的有序列表。

--instructions--

创建一个有序列表,内容是猫咪最讨厌的三件东西,内容可以任意指定。

--hints--

页面应该有一个无序列表,内容是猫咪最喜欢的三件东西。

assert(/Top 3 things cats hate:/i.test($('ol').prev().text()));

页面应该有一个有序列表,内容是猫咪最讨厌的三件东西。

assert(/Things cats love:/i.test($('ul').prev().text()));

页面应该只有一个ul元素。

assert.equal($('ul').length, 1);

页面应该只有一个ol元素。

assert.equal($('ol').length, 1);

ul无序列表应该包含3个li条目。

assert.equal($('ul li').length, 3);

ol有序列表应该包含3个li元素。

assert.equal($('ol li').length, 3);

确保ul无序列表有结束标记。

assert(
  code.match(/<\/ul>/g) &&
    code.match(/<\/ul>/g).length === code.match(/<ul>/g).length
);

确保ol有序列表有结束标记。

assert(
  code.match(/<\/ol>/g) &&
    code.match(/<\/ol>/g).length === code.match(/<ol>/g).length
);

确保每个li条目都有结束标记。

assert(
  code.match(/<\/li>/g) &&
    code.match(/<li>/g) &&
    code.match(/<\/li>/g).length === code.match(/<li>/g).length
);

无序列表里的 li 元素不应该为空。

$('ul li').each((i, val) => assert(val.textContent.replace(/\s/g, '')));

有序列表里的 li 元素不应该为空。

$('ol li').each((i, val) => assert(!!val.textContent.replace(/\s/g, '')));

--solutions--