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

  • 相关阅读:
    WebStorm 9 配置 Live Edit 功能与浏览器实现同步
    开源JS图片裁剪插件
    cropper手机使用实例
    Laravel中的Storage::disk
    laravel删除文件
    cropper.js移动端使用
    资本的一些运作规律及启示
    laravel文件存储、删除、移动等操作
    解决div和父div不上对齐
    ubuntu14.04如何卸载qq
  • 原文地址:https://www.cnblogs.com/YangMT/p/4864020.html
Copyright © 2011-2022 走看看