4.6 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 5efc4f528d6a74d05e68af74 | Passo 56 | 0 | step-56 |
--description--
Existe outra maneira de associar o texto de um elemento input com o elemento em si. Você pode colocar o texto dentro de um elemento label e adicionar um atributo for com o mesmo valor que o atributo id do elemento input.
Associe o texto Loving com a caixa de seleção inserindo apenas o texto Loving em um elemento label e dando a ele um atributo for apropriado.
--hints--
Confira se a caixa de seleção ainda está presente.
assert($('input[type="checkbox"]')[0]);
A caixa de seleção deve ter o atributo id com o valor loving. Eram esperados --fcc-expected-- elementos, mas foram encontrados --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, ' '))
);
Você precisará adicionar um novo elemento label no qual aninhará o texto Loving. Certifique-se de que os dois tenham uma tag de abertura e fechamento.
assert(
document.querySelectorAll('label').length === 3 &&
code.match(/<\/label\>/g).length === 3
);
O novo elemento label deve estar localizado diretamente à direita da caixa de seleção. Certifique-se de que haja um espaço entre os dois elementos.
const checkboxInputElem = $('input[type="checkbox"]')[0];
assert(checkboxInputElem.nextElementSibling.nodeName === 'LABEL');
O novo elemento label não tem um atributo for. Verifique se há um espaço depois do nome da tag de abertura.
const labelElem = $('input[type="checkbox"]')[0].nextElementSibling;
assert(labelElem.hasAttribute('for'));
O novo elemento label deve ter o atributo for com o valor loving. Eram esperados --fcc-expected-- elementos, mas foram encontrados --fcc-actual--.
const labelElem = $('input[type="checkbox"]')[0].nextElementSibling;
assert.equal(labelElem.getAttribute('for'), 'loving');
O texto Loving deve estar dentro do novo elemento label. Você omitiu o texto ou tem um erro de digitação.
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>