--- id: bad87fee1348bd9aede08817 title: Nest an Anchor Element within a Paragraph challengeType: 0 videoUrl: '' localeTitle: 在段落中嵌入锚元素 --- ## Description
您可以在其他文本元素中嵌套链接。
<P>
这是一个<a target="_blank" href="http://freecodecamp.org"> freecodecamp.org </a>的链接供您关注。
</ p>
让我们分解示例:普通文本包含在p元素中:
<p> Here's a ... for you to follow. </p>接下来是anchor元素<a> (需要结束标记</a> ):
<a> ... </a> target是一个锚标记属性,指定打开链接的位置,值"_blank"指定在新标签中打开链接href是一个锚标记属性,其中包含URL地址链接:
<a href="http://freecodecamp.org"> ... </a>在名为anchor text的锚元素中,文本“链接到freecodecamp.org”将显示一个单击的链接:
<a href=" ... ">link to freecodecamp.org</a>示例的最终输出如下所示:

这是freecodecamp.org链接供您关注。

## Instructions
现在,鸟巢现有的a新元素内p元(刚过现有的main元素)。新段落的文本应显示“查看更多猫照片”,其中“猫照片”是一个链接,其余文本是纯文本。
## Tests
```yml tests: - text: '您需要一个链接到“http://freecatphotoapp.com” a元素。' testString: 'assert(($("a[href=\"http://freecatphotoapp.com\"]").length > 0 || $("a[href=\"http://www.freecatphotoapp.com\"]").length > 0), "You need an a element that links to "http://freecatphotoapp.com".");' - text: 你a元素应该有“猫照片”的锚文本 testString: 'assert($("a").text().match(/cat\sphotos/gi), "Your a element should have the anchor text of "cat photos"");' - text: 创建一个新的p周围的元素a元素。 HTML代码中应至少包含3个p标签。 testString: 'assert($("p") && $("p").length > 2, "Create a new p element around your a element. There should be at least 3 total p tags in your HTML code.");' - text: 您a元素应嵌套在新的p元素中。 testString: 'assert(($("a[href=\"http://freecatphotoapp.com\"]").parent().is("p") || $("a[href=\"http://www.freecatphotoapp.com\"]").parent().is("p")), "Your a element should be nested within your new p element.");' - text: 你的p元素应该有“查看更多”文本(后面有一个空格)。 testString: 'assert(($("a[href=\"http://freecatphotoapp.com\"]").parent().text().match(/View\smore\s/gi) || $("a[href=\"http://www.freecatphotoapp.com\"]").parent().text().match(/View\smore\s/gi)), "Your p element should have the text "View more " (with a space after it).");' - text: 您的a元素应该有文字“查看更多”。 testString: 'assert(!$("a").text().match(/View\smore/gi), "Your a element should not have the text "View more".");' - text: 确保每个p元素都有一个结束标记。 testString: 'assert(code.match(/<\/p>/g) && code.match(/

/g).length === code.match(/

p elements has a closing tag.");' - text: 确保每个的a元素具有一个结束标记。 testString: 'assert(code.match(/<\/a>/g) && code.match(//g).length === code.match(/a elements has a closing tag.");' ```

## Challenge Seed
```html

CatPhotoApp

cat photos A cute orange cat lying on its back.

Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.

Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.

```
## Solution
```js // solution required ```