3.2 KiB
id | title | challengeType | dashedName |
---|---|---|---|
5ef9b03c81a63668521804dd | Step 45 | 0 | step-45 |
--description--
Gli elementi label
sono usati per aiutare ad associare il testo di un elemento input
con l'elemento stesso (specialmente per le tecnologie assistive come i lettori di schermo). Ad esempio, <label><input type="radio"> cat</label>
fa sì che facendo clic sulla parola cat
venga selezionato anche il corrispondente pulsante di opzione.
Annida il tuo pulsante di opzione all'interno di un elemento label
.
--hints--
Dovresti assicurarti che il pulsante di opzione sia ancora presente.
assert($('input[type="radio"]')[0]);
Il testo Indoor
dovrebbe essere posizionato direttamente a destra del pulsante di opzione. Assicurati che ci sia uno spazio tra l'elemento e il testo. Hai omesso il testo o hai un refuso.
const radioInputElem = $('input')[0];
assert(
radioInputElem.nextSibling.nodeValue.replace(/\s+/g, ' ').match(/ Indoor/i)
);
L'elemento label
dovrebbe avere un tag di apertura. I tag di apertura hanno questa sintassi: <nomeElemento>
.
assert(document.querySelector('label'));
L'elemento label
dovrebbe avere un tag di chiusura. I tag di chiusura hanno un carattere /
subito dopo il carattere <
.
assert(code.match(/<\/label\>/));
Il pulsante di opzione e il suo testo dovrebbero essere posizionati tra i tag di apertura e chiusura dell'elemento label
.
const labelChildNodes = [...$('form > label')[0].childNodes];
assert(
labelChildNodes.filter((childNode) => childNode.nodeName === 'INPUT').length
);
--seed--
--seed-contents--
<html>
<body>
<h1>CatPhotoApp</h1>
<main>
<section>
<h2>Cat Photos</h2>
<!-- TODO: Add link to cat photos -->
<p>Click here to view more <a target="_blank" href="https://freecatphotoapp.com">cat photos</a>.</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">
--fcc-editable-region--
<input type="radio"> Indoor
--fcc-editable-region--
<input type="text" name="catphotourl" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</section>
</main>
</body>
</html>