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

  • 相关阅读:
    iOS的图片:解码(CPU)与内存(缓存)
    iOS离屏渲染的解释:渲染与cpu、gpu
    渲染、render与绘制
    算法沉思:算法的构成
    待阅备份
    iOS进阶之页面性能优化
    iOS--性能优化--保持界面流畅
    iOS开发中的Markdown渲染
    OS开发小记:iOS富文本框架DTCoreText在UITableView上的使用
    iOS UI的几种模式
  • 原文地址:https://www.cnblogs.com/YangMT/p/4864020.html
Copyright © 2011-2022 走看看