4.5 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 5efc4f528d6a74d05e68af74 | Paso 56 | 0 | step-56 |
--description--
Hay otra manera de asociar un texto con el elemento input. Puedes anidar un texto dentro de un elemento label y añadirle un atributo for con el mismo valor del atributo id del elemento input.
Associate the text Loving with the checkbox by nesting only the text Loving in a label element and giving it an appropriate for attribute.
--hints--
Asegúrate de que el checkbox aún está presente.
assert($('input[type="checkbox"]')[0]);
Tu checkbox, aún debe tener un atributo id con el valor loving. Se esperaba --fcc-expected--, pero se encontró --fcc-actual--.
assert.equal($('input[type="checkbox"]')[0].id, 'loving');
The text Loving should be wrapped in a label element.
const checkboxInputElem = $('input[type="checkbox"]')[0];
assert(
/Loving/i.test(checkboxInputElem.nextElementSibling.innerText.replace(/\s+/g, ' '))
);
Necesitas añadir un nuevo elemento label en el cual anidar el texto Loving. No olvides su etiqueta de apertura y cierre.
assert(
document.querySelectorAll('label').length === 3 &&
code.match(/<\/label\>/g).length === 3
);
El nuevo elemento label debe estar inmediatamente a la derecha de tu checkbox. Asegúrate de que hay un espacio entre los dos elementos.
const checkboxInputElem = $('input[type="checkbox"]')[0];
assert(checkboxInputElem.nextElementSibling.nodeName === 'LABEL');
El nuevo elemento label no tiene un atributo for. Comprueba que hay un espacio después del nombre de la etiqueta de apertura.
const labelElem = $('input[type="checkbox"]')[0].nextElementSibling;
assert(labelElem.hasAttribute('for'));
El nuevo elemento label debe tener un atributo for con el valor loving. Se esperaba --fcc-expected--, pero se encontró --fcc-actual--.
const labelElem = $('input[type="checkbox"]')[0].nextElementSibling;
assert.equal(labelElem.getAttribute('for'), 'loving');
El texto Loving debe estar anidado dentro del nuevo elemento label. Probablemente no has añadido el texto o tienes un error tipográfico.
const labelElem = document.querySelector('label[for="loving"]');
assert(labelElem.textContent.replace(/\s/g, '').match(/Loving/i));
There should be a space between your checkbox and your new label element.
assert.match(code, />\s+<label\s+for\s*=\s*('|")loving/);
--seed--
--seed-contents--
<html>
<body>
<main>
<h1>CatPhotoApp</h1>
<section>
<h2>Cat Photos</h2>
<!-- TODO: Add link to cat photos -->
<p>See more <a target="_blank" href="https://freecatphotoapp.com">cat photos</a> in our gallery.</p>
<a href="https://freecatphotoapp.com"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
</section>
<section>
<h2>Cat Lists</h2>
<h3>Things cats love:</h3>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<figure>
<img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/lasagna.jpg" alt="A slice of lasagna on a plate.">
<figcaption>Cats <em>love</em> lasagna.</figcaption>
</figure>
<h3>Top 3 things cats hate:</h3>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
<figure>
<img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/cats.jpg" alt="Five cats looking around a field.">
<figcaption>Cats <strong>hate</strong> other cats.</figcaption>
</figure>
</section>
<section>
<h2>Cat Form</h2>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<fieldset>
<legend>Is your cat an indoor or outdoor cat?</legend>
<label><input id="indoor" type="radio" name="indoor-outdoor" value="indoor"> Indoor</label>
<label><input id="outdoor" type="radio" name="indoor-outdoor" value="outdoor"> Outdoor</label>
</fieldset>
<fieldset>
<legend>What's your cat's personality?</legend>
--fcc-editable-region--
<input id="loving" type="checkbox"> Loving
--fcc-editable-region--
</fieldset>
<input type="text" name="catphotourl" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</section>
</main>
</body>
</html>