2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
id: bad87fee1348bd9aedf08801
|
2020-12-16 00:37:30 -07:00
|
|
|
title: 用 p 元素代表段落
|
2018-10-10 18:03:03 -04:00
|
|
|
challengeType: 0
|
2019-12-26 20:05:59 +08:00
|
|
|
videoUrl: 'https://scrimba.com/p/pVMPUv/ceZ7DtN'
|
|
|
|
forumTopicId: 18202
|
2021-01-13 03:31:00 +01:00
|
|
|
dashedName: inform-with-the-paragraph-element
|
2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --description--
|
|
|
|
|
2021-01-08 11:20:48 -08:00
|
|
|
`p` 是 `paragraph` 的缩写,通常用来创建一个段落,就和你写作文一样。
|
2020-12-16 00:37:30 -07:00
|
|
|
|
2019-12-26 20:05:59 +08:00
|
|
|
你可以像这样创建一个段落:
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
`<p>I'm a p tag!</p>`
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --instructions--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2021-01-08 11:20:48 -08:00
|
|
|
请在 `h2` 元素下方添加一个 `p` 元素,元素内容是 `Hello Paragraph`。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --hints--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2021-01-08 11:20:48 -08:00
|
|
|
应包含一个 `p` 元素。
|
2020-12-16 00:37:30 -07:00
|
|
|
|
|
|
|
```js
|
|
|
|
assert($('p').length > 0);
|
2018-10-10 18:03:03 -04:00
|
|
|
```
|
|
|
|
|
2021-01-08 11:20:48 -08:00
|
|
|
`p` 元素的内容文本应为 `Hello Paragraph`。
|
2020-12-16 00:37:30 -07:00
|
|
|
|
|
|
|
```js
|
|
|
|
assert.isTrue(/hello(\s)+paragraph/gi.test($('p').text()));
|
|
|
|
```
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2021-01-08 11:20:48 -08:00
|
|
|
`p` 元素应有结束标签。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
```js
|
|
|
|
assert(
|
|
|
|
code.match(/<\/p>/g) &&
|
|
|
|
code.match(/<\/p>/g).length === code.match(/<p/g).length
|
|
|
|
);
|
|
|
|
```
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2021-01-13 03:31:00 +01:00
|
|
|
# --seed--
|
|
|
|
|
|
|
|
## --seed-contents--
|
|
|
|
|
|
|
|
```html
|
|
|
|
<h1>Hello World</h1>
|
|
|
|
<h2>CatPhotoApp</h2>
|
|
|
|
```
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --solutions--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2021-01-13 03:31:00 +01:00
|
|
|
```html
|
|
|
|
<h1>Hello World</h1>
|
|
|
|
<h2>CatPhotoApp</h2>
|
|
|
|
<p>Hello Paragraph</p>
|
|
|
|
```
|