59 lines
1.9 KiB
Markdown
59 lines
1.9 KiB
Markdown
---
|
|
id: bad87fee1348bd9aedf08817
|
|
title: '用 # 號來創建鏈接佔位符'
|
|
challengeType: 0
|
|
videoUrl: 'https://scrimba.com/p/pVMPUv/cMdkytL'
|
|
forumTopicId: 18230
|
|
dashedName: make-dead-links-using-the-hash-symbol
|
|
---
|
|
|
|
# --description--
|
|
|
|
有時你想爲網站添加一個 `a` 元素,但還不確定要將它鏈接到哪裏。
|
|
|
|
當你使用 `JavaScript` 更改鏈接的指向時,這也很方便,我們將在後面的課程中介紹。
|
|
|
|
# --instructions--
|
|
|
|
`href` 屬性的當前值是指向 “`https://www.freecatphotoapp.com`”。 請將 `href` 屬性的值替換爲`#`,以此來創建鏈接佔位符。
|
|
|
|
例如: `href="#"`
|
|
|
|
# --hints--
|
|
|
|
`a` 的 `href` 屬性值應爲 "#"。
|
|
|
|
```js
|
|
assert($('a').attr('href') === '#');
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```html
|
|
<h2>CatPhotoApp</h2>
|
|
<main>
|
|
<p>Click here to view more <a href="https://www.freecatphotoapp.com" target="_blank">cat photos</a>.</p>
|
|
|
|
<img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" 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="#" target="_blank">cat photos</a>.</p>
|
|
|
|
<img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" 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>
|
|
```
|