山本

导航

DOM学习练习

<head>
    <title></title>
    <script type="text/javascript">
        function addnode() {
        //添加段落
//            var pnode = document.createElement('p');
//            var tnode = document.createTextNode('河北软件职业技术学院');
//            pnode.appendChild(tnode);
//            document.body.appendChild(pnode);
            //添加链接
            var anode = document.createElement('a');
            var tnode = document.createTextNode('百度');
            anode.appendChild(tnode);
            anode.setAttribute('href', 'http://www.baidu.com');
            anode.setAttribute('target', '_blank'); //跳转到另外的一个页面
            document.body.appendChild(anode);
          }
    </script>
</head>
<body>
    <input id="Button1" type="button" value="button" onclick="addnode();"/>
</body>

posted on 2013-04-15 23:39  高级菜鸟  阅读(124)  评论(0编辑  收藏  举报