源代码 :
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>开源教程(ossoft.cn)</title> <script> function changeTarget(){ document.getElementById('runoob').target="_blank"; } </script> </head> <body> <a id="runoob" href="">访问开源教程</a> <br><br> <input type="button" onclick="changeTarget()" value="修改target"> <p>尝试在你单击按钮之前点击链接。</p> </body> </html>
运行结果