5.2 KiB
5.2 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
bad87fee1348bd9aede08817 | Nest an Anchor Element within a Paragraph | 0 | Anidar un elemento de anclaje dentro de un párrafo |
Description
<p>Desglosemos el ejemplo: el texto normal está envuelto en el elemento
Aquí hay un enlace <a target="_blank" href="http://freecodecamp.org"> a freecodecamp.org </a> para que lo siga.
</p>
p
: <p> Here's a ... for you to follow. </p>
siguiente es el elemento de anchor
<a>
(que requiere una etiqueta de cierre </a>
): <a> ... </a>
target
es un atributo de etiqueta de anclaje que especifica dónde abrir el enlace y el valor "_blank"
especifica que se abra el enlace en una nueva pestaña href
es un atributo de etiqueta de anclaje que contiene la dirección URL de el enlace: <a href="http://freecodecamp.org"> ... </a>
El texto, "link to freecodecamp.org" , dentro del elemento de anchor text
llamado anchor text
, mostrará un enlace para hacer clic: <a href=" ... ">link to freecodecamp.org</a>
El resultado final del ejemplo se verá así: Aquí hay un enlace a freecodecamp.org para que lo sigas.
Instructions
a
elemento dentro de un nuevo p
elemento (justo a continuación de la main
elemento). El nuevo párrafo debe tener un texto que diga "Ver más fotos de gatos", donde "fotos de gatos" es un enlace, y el resto del texto es texto sin formato. Tests
tests:
- text: 'Es necesario un <code>a</code> elemento que une a "http://freecatphotoapp.com".'
testString: 'assert(($("a[href=\"http://freecatphotoapp.com\"]").length > 0 || $("a[href=\"http://www.freecatphotoapp.com\"]").length > 0), "You need an <code>a</code> element that links to "http://freecatphotoapp.com".");'
- text: Su <code>a</code> elemento debe tener el texto de anclaje de fotos "gato"
testString: 'assert($("a").text().match(/cat\sphotos/gi), "Your <code>a</code> element should have the anchor text of "cat photos"");'
- text: Crear un nuevo <code>p</code> elemento alrededor de su <code>a</code> elemento. Debe haber al menos 3 etiquetas <code>p</code> en total en su código HTML.
testString: 'assert($("p") && $("p").length > 2, "Create a new <code>p</code> element around your <code>a</code> element. There should be at least 3 total <code>p</code> tags in your HTML code.");'
- text: Su <code>a</code> elemento debe estar anidada dentro de su nueva <code>p</code> elemento.
testString: 'assert(($("a[href=\"http://freecatphotoapp.com\"]").parent().is("p") || $("a[href=\"http://www.freecatphotoapp.com\"]").parent().is("p")), "Your <code>a</code> element should be nested within your new <code>p</code> element.");'
- text: Su elemento <code>p</code> debe tener el texto "Ver más" (con un espacio detrás de él).
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 <code>p</code> element should have the text "View more " (with a space after it).");'
- text: Su <code>a</code> elemento <em>no</em> debería tener el texto "Ver más".
testString: 'assert(!$("a").text().match(/View\smore/gi), "Your <code>a</code> element should <em>not</em> have the text "View more".");'
- text: Asegúrese de que cada uno de sus elementos <code>p</code> tenga una etiqueta de cierre.
testString: 'assert(code.match(/<\/p>/g) && code.match(/<p/g) && code.match(/<\/p>/g).length === code.match(/<p/g).length, "Make sure each of your <code>p</code> elements has a closing tag.");'
- text: Asegúrese de que cada uno de sus <code>a</code> elementos tiene una etiqueta de cierre.
testString: 'assert(code.match(/<\/a>/g) && code.match(/<a/g) && code.match(/<\/a>/g).length === code.match(/<a/g).length, "Make sure each of your <code>a</code> elements has a closing tag.");'
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.</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