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();

  • 相关阅读:
    全国省市县三级数据库
    多源教学数据管理系统之团队课设博客
    1.判断字符串中的字符是否Unique
    [转载]linux防火墙基础和管理设置iptables规则
    (转)Sed使用详解
    2.判断回文(Anagrams)
    【转载】关于23 种设计模式的有趣见解
    macbook M1芯片在centos8下安装k8s笔记
    Winform 学习初级 从WebForm到WinForm
    如何建立数据模型
  • 原文地址:https://www.cnblogs.com/YangMT/p/4864020.html
Copyright © 2011-2022 走看看