2018-10-10 22:03:03 +00:00
---
id: bad87fee1348bd9aedf08817
2020-12-16 07:37:30 +00:00
title: '用 # 号来创建链接占位符'
2018-10-10 22:03:03 +00:00
challengeType: 0
2019-12-26 12:05:59 +00:00
videoUrl: 'https://scrimba.com/p/pVMPUv/cMdkytL'
forumTopicId: 18230
2021-01-13 02:31:00 +00:00
dashedName: make-dead-links-using-the-hash-symbol
2018-10-10 22:03:03 +00:00
---
2020-12-16 07:37:30 +00:00
# --description--
2018-10-10 22:03:03 +00:00
2021-02-06 04:42:36 +00:00
有时你想为网站添加一个 `a` 元素,但还不确定要将它链接到哪里。
2018-10-10 22:03:03 +00:00
2021-02-06 04:42:36 +00:00
当你使用 `JavaScript` 更改链接的指向时,这也很方便,我们将在后面的课程中介绍。
2018-10-10 22:03:03 +00:00
2020-12-16 07:37:30 +00:00
# --instructions--
2018-10-10 22:03:03 +00:00
2021-05-09 19:42:02 +00:00
`href` 属性的当前值是指向 “`https://www.freecatphotoapp.com`”。 请将 `href` 属性的值替换为`#`,以此来创建链接占位符。
2018-10-10 22:03:03 +00:00
2020-12-16 07:37:30 +00:00
例如: `href="#"`
2018-10-10 22:03:03 +00:00
2020-12-16 07:37:30 +00:00
# --hints--
2018-10-10 22:03:03 +00:00
2021-01-08 19:20:48 +00:00
`a` 的 `href` 属性值应为 "#"。
2018-10-10 22:03:03 +00:00
2020-12-16 07:37:30 +00:00
```js
assert($('a').attr('href') === '#');
2018-10-10 22:03:03 +00:00
```
2021-01-13 02:31:00 +00:00
# --seed--
## --seed-contents--
```html
< h2 > CatPhotoApp< / h2 >
< main >
2021-05-09 19:42:02 +00:00
< p > Click here to view more < a href = "https://www.freecatphotoapp.com" target = "_blank" > cat photos< / a > .< / p >
2021-01-13 02:31:00 +00:00
2021-05-09 19:42:02 +00:00
< img src = "https://www.bit.ly/fcc-relaxing-cat" alt = "A cute orange cat lying on its back." >
2021-01-13 02:31:00 +00:00
< 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 >
```
2020-12-16 07:37:30 +00:00
# --solutions--
2018-10-10 22:03:03 +00:00
2021-01-13 02:31:00 +00:00
```html
< h2 > CatPhotoApp< / h2 >
< main >
< p > Click here to view more < a href = "#" target = "_blank" > cat photos< / a > .< / p >
2021-02-06 04:42:36 +00:00
2021-05-09 19:42:02 +00:00
< img src = "https://www.bit.ly/fcc-relaxing-cat" alt = "A cute orange cat lying on its back." >
2021-02-06 04:42:36 +00:00
2021-01-13 02:31:00 +00:00
< 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 >
```