Skip to content

Commit cbea84b

Browse files
committed
docs(elements): add a.md
1 parent 37156b2 commit cbea84b

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

chapters.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,5 @@
5151
- bom/: 浏览器模型
5252
- bom/same-origin.md: 同源限制
5353
- bom/location.md: Location 对象,URL 对象,URLSearchParams 对象
54+
- elements/: 网页元素接口
55+
- elements/a.md: <a>

docs/elements/a.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# <a> 元素
2+
3+
`<a>`元素用来设置超级链接。除了网页元素的通用接口(`Node`接口、`Element`接口、`HTMLElement`接口),它还继承了`HTMLAnchorElement`接口和`HTMLHyperlinkElementUtils`接口。
4+
5+
## HTMLAnchorElement 接口
6+
7+
### 属性
8+
9+
**(1)HTMLAnchorElement.accessKey**
10+
11+
`accessKey`属性用来读写`<a>`元素的快捷键。
12+
13+
```javascript
14+
// HTML 代码如下
15+
// <a id="test" href="http://example.com">test</a>
16+
var a = document.getElementById('a');
17+
a.accessKey = 'k';
18+
```
19+
20+
上面代码设置`<a>`元素的快捷键为`k`,以后只要按下这个快捷键,浏览器就会跳转到`example.com`
21+
22+
注意,不同的浏览器在不同的操作系统下,唤起快捷键的功能键组合是[不一样](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey)的。比如,Chrome 浏览器在 Linux 系统下,需要按下`Alt + k`,才会跳转到`example.com`
23+
24+

0 commit comments

Comments
 (0)