2.1 KiB

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

--description--

HTML 中有用于创建有序列表的特定元素。

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

例如:

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

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

--instructions--

请创建一个有序列表,内容是猫咪最讨厌的三样东西(Top 3 things cats hate:),内容可以任意指定。

--hints--

应包含一个有序列表,内容是猫咪最讨厌的三样东西(Top 3 things cats hate:)。

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

应包含有一个无序列表,内容是猫咪最喜欢的东西(Things cats love:)。

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(__helpers.removeWhiteSpace(val.textContent))
);

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

$('ol li').each((i, val) =>
  assert(!!__helpers.removeWhiteSpace(val.textContent))
);

--solutions--