HTMLAnchorElement: href 屬性

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

HTMLAnchorElement.href 屬性是一個 stringifier,它返回一個包含整個 URL 的字串,並允許更新 href。

字串。

示例

js
// An <a id="myAnchor" href="https://mdn.club.tw/en-US/HTMLAnchorElement"> element is in the document
const anchor = document.getElementById("myAnchor");
anchor.href; // returns 'https://mdn.club.tw/en-US/HTMLAnchorElement'

規範

規範
HTML
# dom-hyperlink-href-dev

瀏覽器相容性

另見