--- id: bad87fee1348bd9aede08835 title: 元素嵌套 challengeType: 0 videoUrl: 'https://scrimba.com/p/pVMPUv/cNW4kC3' forumTopicId: 18246 dashedName: nest-many-elements-within-a-single-div-element --- # --description-- `div` 元素也叫內容劃分元素,是一個包裹其他元素的通用容器。 它也是 HTML 中出現頻率最高的元素。 和其他普通元素一樣,你可以用 `
` 來標記一個 `div` 元素的開始,用 `
` 來標記一個 `div` 元素的結束。 # --instructions-- 將你的列表“貓喜歡的三件事”和“貓最討厭的三件事”放入同一個 `div` 元素中。 提示:你可以在第一個 `

` 之前插入 `div` 開始標記,在 `` 之後插入 `div` 結束標籤。 這樣,所有的列表都會位於 `div` 之內。 # --hints-- 所有的 `p` 元素都應嵌套在 `div` 元素中。 ```js assert($('div').children('p').length > 1); ``` 所有的 `ul` 元素都應嵌套在 `div` 元素中。 ```js assert($('div').children('ul').length > 0); ``` 所有的 `ol` 元素都應嵌套在 `div` 元素中。 ```js assert($('div').children('ol').length > 0); ``` `div` 元素應有結束標籤。 ```js assert( code.match(/<\/div>/g) && code.match(/<\/div>/g).length === code.match(/

/g).length ); ``` # --seed-- ## --seed-contents-- ```html

CatPhotoApp

Click here to view more cat photos.

A cute orange cat lying on its back.

Things cats love:

Top 3 things cats hate:

  1. flea treatment
  2. thunder
  3. other cats


``` # --solutions-- ```html

CatPhotoApp

Click here to view more cat photos.

A cute orange cat lying on its back.

Things cats love:

  • cat nip
  • laser pointers
  • lasagna

Top 3 things cats hate:

  1. flea treatment
  2. thunder
  3. other cats


```