freeCodeCamp/curriculum/challenges/russian/01-responsive-web-design/basic-html-and-html5/link-to-internal-sections-o...

6.0 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
bad88fee1348bd9aedf08816 Link to Internal Sections of a Page with Anchor Elements 0 Ссылка на внутренние разделы страницы с элементами привязки

Description

Элементы привязки также могут использоваться для создания внутренних ссылок для перехода к различным разделам веб-страницы. Чтобы создать внутреннюю ссылку, вы назначаете атрибут href ссылки на хэш-символ # плюс значение атрибута id для элемента, к которому вы хотите внутренне связать, обычно дальше вниз по странице. Затем вам нужно добавить тот же атрибут id к элементу, к которому вы привязываетесь. id - это атрибут, который однозначно описывает элемент. Ниже приведен пример внутренней привязной ссылки и ее целевого элемента:
<a href="#contacts-header"> Контакты </a>
...
<h2 id = "contacts-header"> Контакты </ h2>
Когда пользователи нажимают ссылку «Контакты», они будут отправлены в раздел веб-страницы с элементом заголовка « Контакты» .

Instructions

Измените внешнюю ссылку на внутреннюю ссылку, изменив атрибут href на «#footer» и текст «Фотографии кошки» на «Перейти к нижнему». Удалите атрибут target="_blank" из тега привязки, поскольку это заставляет связанный документ открываться на вкладке нового окна. Затем добавьте атрибут id со значением «footer» в элемент <footer> в нижней части страницы.

Tests

tests:
  - text: На вашей странице должен быть только один тег привязки.
    testString: 'assert($("a").length == 1, "There should be only one anchor tag on your page.");'
  - text: На вашей странице должен быть только один <code>footer</code> тег.
    testString: 'assert($("footer").length == 1, "There should be only one <code>footer</code> tag on your page.");'
  - text: 'Тег <code>a</code> должен иметь атрибут <code>href</code> установленный на «#footer».'
    testString: 'assert($("a").eq(0).attr("href") == "#footer", "The <code>a</code> tag should have an <code>href</code> attribute set to "#footer".");'
  - text: Тег <code>a</code> должен не иметь <code>target</code> атрибута
    testString: 'assert(typeof $("a").eq(0).attr("target") == typeof undefined || $("a").eq(0).attr("target") == true, "The <code>a</code> tag should not have a <code>target</code> attribute");'
  - text: Текст должен быть «Перейти к низу». <code>a</code>
    testString: 'assert($("a").eq(0).text().match(/Jump to Bottom/gi), "The <code>a</code> text should be "Jump to Bottom".");'
  - text: Тег <code>footer</code> должен иметь атрибут <code>id</code> установленный в «нижний колонтитул».
    testString: 'assert($("footer").eq(0).attr("id") == "footer", "The <code>footer</code> tag should have an <code>id</code> attribute set to "footer".");'

Challenge Seed

<h2>CatPhotoApp</h2>
<main>

  <a href="http://freecatphotoapp.com" target="_blank">cat photos</a>

  <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. Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched. 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. 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.</p>
  <p>Meowwww loved it, hated it, loved it, hated it yet spill litter box, scratch at owner, destroy all furniture, especially couch or lay on arms while you're using the keyboard. Missing until dinner time toy mouse squeak roll over. With tail in the air lounge in doorway. Man running from cops stops to pet cats, goes to jail.</p>
  <p>Intently stare at the same spot poop in the plant pot but kitten is playing with dead mouse. Get video posted to internet for chasing red dot leave fur on owners clothes meow to be let out and mesmerizing birds leave fur on owners clothes or favor packaging over toy so purr for no reason. Meow to be let out play time intently sniff hand run outside as soon as door open yet destroy couch.</p>

</main>

<footer>Copyright Cat Photo App</footer>

Solution

// solution required