* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
79 lines
2.3 KiB
Markdown
79 lines
2.3 KiB
Markdown
---
|
|
id: bad87fee1348bd9aedf08820
|
|
title: Turn an Image into a Link
|
|
challengeType: 0
|
|
videoUrl: 'https://scrimba.com/p/pVMPUv/cRdBnUr'
|
|
forumTopicId: 18327
|
|
dashedName: turn-an-image-into-a-link
|
|
---
|
|
|
|
# --description--
|
|
|
|
You can make elements into links by nesting them within an `a` element.
|
|
|
|
Nest your image within an `a` element. Here's an example:
|
|
|
|
`<a href="#"><img src="https://bit.ly/fcc-running-cats" alt="Three kittens running towards the camera."></a>`
|
|
|
|
Remember to use `#` as your `a` element's `href` property in order to turn it into a dead link.
|
|
|
|
# --instructions--
|
|
|
|
Place the existing image element within an `a` (*anchor*) element.
|
|
|
|
Once you've done this, hover over your image with your cursor. Your cursor's normal pointer should become the link clicking pointer. The photo is now a link.
|
|
|
|
# --hints--
|
|
|
|
The existing `img` element should be nested within an `a` element.
|
|
|
|
```js
|
|
assert($('a').children('img').length > 0);
|
|
```
|
|
|
|
Your `a` element should be a dead link with a `href` attribute set to `#`.
|
|
|
|
```js
|
|
assert(new RegExp('#').test($('a').children('img').parent().attr('href')));
|
|
```
|
|
|
|
Each of your `a` elements should have a closing tag.
|
|
|
|
```js
|
|
assert(
|
|
code.match(/<\/a>/g) &&
|
|
code.match(/<a/g) &&
|
|
code.match(/<\/a>/g).length === code.match(/<a/g).length
|
|
);
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```html
|
|
<h2>CatPhotoApp</h2>
|
|
<main>
|
|
<p>Click here to view more <a href="#">cat photos</a>.</p>
|
|
|
|
<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>
|
|
```
|
|
|
|
# --solutions--
|
|
|
|
```html
|
|
<h2>CatPhotoApp</h2>
|
|
<main>
|
|
<p>Click here to view more <a href="#">cat photos</a>.</p>
|
|
|
|
<a href="#"><img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>
|
|
|
|
<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>
|
|
```
|