dom document属性练习

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=GBK">
        <title>Untitled Document</title>
    </head>
    <body>
        <script type="text/javascript">
            function run(){
                var idNode=document.getElementById("divid");
                var text=idNode.innerHTML;
                idNode.innerHTML="div的文本被我该了哈哈"
            //    alert(idNode.nodeValue+":"+idNode.nodeType+":"+idNode.nodeName);
                alert(text);
            }
            function run1(){
                var Nodes=document.getElementsByName("user");
                alert(Nodes[0].value);
            }
            function run2(){
                var Nodes=document.getElementsByTagName("a");
            //    alert(Nodes.length);
                alert(Nodes[1].innerHTML);
            }
        </script>
        <input type="button" value="document" onclick="run2()"/>
        <div id="divid">div标签练习</div>
        <input type="text" name="user"/>
        <a href="http://www.baidu.com">百度网站</a>
        <a href="http://www.google.com">谷歌网站</a>
    </body>
</html>

posted on 2012-11-03 12:24  蝌蚪的精神  阅读(115)  评论(0编辑  收藏  举报

导航