Anchor href 属性
 Anchor对象
 Anchor对象定义和用法
href 属性可设置或返回链接中 href 属性的值。
href 属性指定了被链资源的 URL。
语法
设置 href 属性:
anchorObject.href="URL"
返回 href 属性:
anchorObject.href
| 值 | 描述 | 
|---|---|
| URL | 被链资源的 URL | 
浏览器支持





所有主要浏览器都支持 href 属性
实例
实例
返回链接中 href 属性的值:
<!DOCTYPE html>
<html>
<head> 
<meta charset="UTF-8"> 
<title>小鸟启蒙(facesoho.com)</title> 
</head>
<body>
 
<p><a id="facesoho" href="//www.facesoho.com/">小鸟启蒙</a></p>
<script>
document.write("返回 href 链接: ");
document.write(document.getElementById('facesoho').href);
</script>
 
</body>
</html>
尝试一下 »
 Anchor对象
 Anchor对象
尊贵的董事大人
英文标题不为空时 视为本栏投稿
需要关键字 描述 英文标题