DOM 学习手笔 常用属性
更改一个链接的文本,地址,target
View Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>更改一个链接的文本,地址,target</title> <script> function changeLink(){ var myAnchor = document.getElementById('myAnchor'); myAnchor.innerHTML = "访问我的博客"; myAnchor.href = "http://www.cnblogs.com/zzu-han"; myAnchor.target = "_blank"; } </script> </head> <body> <a id="myAnchor" href="#">访问Microsoft</a> <input type="button" onclick="changeLink()" value="改变连接" /> </body> </html>
是