zoukankan      html  css  js  c++  java
  • DOM对象操作HTML元素和消息对话框(alert,confirm,prompt)(二)

    如果你是真的学习请把下面的敲一遍

    <div id="divid">
        <p id="pid">div内的p元素</p>
        nihaoya
    </div>

    function getParentNode(){
            var childNode=document.getElementById("pid");
            var parentnode = childNode.parentNode;
            alert(parentnode.nodeName);
        }
        function createElementNode(){
            var body=document.body;
            var input=document.createElement("input");
            input.type="button";
            input.value="按钮";
            input.onclick=function(){
                alert("我是使用document.createElement("input")创建的一个按钮");
            }
            body.appendChild(input);
        }
        function createTextNode(){
            var body=document.body;
            var text=document.createTextNode("wojiaoyangmaotou");
            body.appendChild(text);
        }
        function insertBefore(){
            var div=document.getElementById("divid");
            var pid=document.getElementById("pid");
            var childnode=document.createTextNode("输入的用户名或密码错误");
            div.insertBefore(childnode,pid);
        }
        function removechild(){
            var div=document.getElementById("divid");
            var pid=document.getElementById("pid");
            div.removeChild(pid);
        }
        function getsize(){
            var width=document.body.offsetWidth||document.documentElement.offsetWidth;
            var height=document.body.offsetHeight||document.documentElement.offsetHeight;
            alert(width+","+height);
        }

        //getParentNode();
        //createElementNode();
        //createTextNode();
        //insertBefore();
        //removechild();
        getsize();

  • 相关阅读:
    文件
    模块
    异常
    抽象
    条件,循环
    centos6.4 64位下安装nfs文件共享系统
    YUM安装删除软件
    apache常用的两种工作模式 prefork和worker
    shell不打印
    APACHE安装配置说明
  • 原文地址:https://www.cnblogs.com/YangMT/p/4864020.html
Copyright © 2011-2022 走看看