HTMLAnchorElement.href
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
io error: No such file or directory (os error 2) (/home/runner/work/yari/yari/mdn/translated-content/files/zh-cn/web/api/htmlanchorelement/index.md)
HTMLAnchorElement.href
属性是一个返回包含整个 URL 的字符串的 stringifier,且允许 href 被更新。
值
一个字符串。
示例
js
// 假设 <a id="myAnchor" href="https://developer.mozilla.org/en-US/HTMLAnchorElement"> 元素在文档内
const anchor = document.getElementById("myAnchor");
anchor.href; // 返回 'https://developer.mozilla.org/en-US/HTMLAnchorElement'
规范
Specification |
---|
HTML Standard # dom-hyperlink-href-dev |
浏览器兼容性
BCD tables only load in the browser
参见
- 所属的
HTMLAnchorElement
接口。