Link href 属性
![Link 对象参考手册](https://image-10001577.image.myqcloud.com/upload/3/20170423/14929407413677.gif)
定义和用法
href 属性是一个可读可写的字符串,可设置或返回当前显示的文档的完整 URL。
语法
设置 href 属性:
linkObject.href = "URL"
返回 href 属性:
linkObject.href
浏览器支持
所有主要浏览器都支持 href 属性
实例
点击一个按钮时切换样式表:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>蜜蜂教程(mifengjc.com)</title> <link id="style1" rel="stylesheet" type="text/css" href="/examples/style1.css"> <script> function displayResult() { document.getElementById("style1").href = "style2.css"; } </script> </head> <body> <h1>我的网站主页</h1> <button type="button" onclick="displayResult()">切换样式表</button> </body> </html>
![Link 对象参考手册](https://image-10001577.image.myqcloud.com/upload/3/20170423/14929407439603.gif)