freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/basic-html-and-html5/link-to-external-pages-with...

2.3 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
bad87fee1348bd9aedf08816 Link to External Pages with Anchor Elements 0 链接到具有锚元素的外部页面

Description

您可以使用anchor元素链接到网页外部的内容。 anchor元素需要一个名为href属性的目标Web地址。他们还需要锚文本。这是一个例子 <a href="https://freecodecamp.org">this links to freecodecamp.org</a>然后你的浏览器会显示文本“这个链接到freecodecamp.org”作为你可以点击的链接。该链接将带您到网址https://www.freecodecamp.org

Instructions

创建一个链接到http://freecatphotoapp.com a元素,并将“猫照片”作为其anchor text

Tests

tests:
  - text: 你<code>a</code>元素应该有“猫照片”的<code>anchor text</code> 。
    testString: 'assert((/cat photos/gi).test($("a").text()), "Your <code>a</code> element should have the <code>anchor text</code> of "cat photos".");'
  - text: '你需要一个链接到<code>http://freecatphotoapp .com</code> <code>a</code>元素'
    testString: 'assert(/http:\/\/(www\.)?freecatphotoapp\.com/gi.test($("a").attr("href")), "You need an <code>a</code> element that links to <code>http&#58;//freecatphotoapp<wbr>.com</code>");'
  - text: 确保您<code>a</code>元素具有结束标记。
    testString: 'assert(code.match(/<\/a>/g) && code.match(/<\/a>/g).length === code.match(/<a/g).length, "Make sure your <code>a</code> element has a closing tag.");'

Challenge Seed

<h2>CatPhotoApp</h2>
<main>



  <img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back.">

  <p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
  <p>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
</main>

Solution

// solution required