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
|
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
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
有时你想为网站添加一个 `a`,但如果你还不确定要将它链接到哪儿,这时可以使用链接占位符。
|
2018-10-10 22:03:03 +00:00
|
|
|
|
2020-12-16 07:37:30 +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
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
`href`属性的当前值是指向 "`https://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
|
|
|
|
2020-12-16 07:37:30 +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
|
|
|
```
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
# --solutions--
|
2018-10-10 22:03:03 +00:00
|
|
|
|