http://www.w3schools.com/js/js_htmldom_nodes.asp

var child = document.getElementById("p1");
child.parentNode.removeChild(child);

 

http://www.w3schools.com/jsref/met_document_createelement.asp

var btn = document.createElement("BUTTON");        // Create a <button> element
var t = document.createTextNode("CLICK ME");       // Create a text node
btn.appendChild(t);                                // Append the text to <button>
document.body.appendChild(btn);   

 

 

MSDN

https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement

 

document.body.onload = addElement;

function addElement () {

// create a new div element

// and give it some content

var newDiv = document.createElement("div");

var newContent = document.createTextNode("Hi there and greetings!");

newDiv.appendChild(newContent); //add the text node to the newly created div.

// add the newly created element and its content into the DOM

var currentDiv = document.getElementById("div1");

document.body.insertBefore(newDiv, currentDiv); }

 

See also

 

js createElement的更多相关文章

  1. js createElement appendChild createTextNode用法

    xml不支持innerHTML 1 <p id="bj">北京</p> <script type="text/javascript" ...

  2. js创建节点,小试牛刀

    实现如下的功能 非常简单的一个小训练. 思想: 1.首先创建text和一个button 代码如下. <body> <input type="text" id=&q ...

  3. vue系列文章 --- 源码目录结构整理(三)

    vue的版本是:^2.6.10 结构如下: |----- vue | |--- dist # 打包之后的目录vue文件 | | |--- vue.common.dev.js | | |--- vue. ...

  4. flutter、rn、uni-app比较

    前言 每当我们评估新技术时要问的第一个问题就是“它会给我们的业务和客户带来哪些价值?”,工程师们很容易对闪闪发光的新事物着迷,却经常会忽略这些新事物其实可能对我们的客户没有任何好处,反而只会让现有的工 ...

  5. ReactElement源码笔记

    ReactElement 源码笔记 ReactElement通过 createElement创建,调用该方法需要 传入三个参数: type config children type指代这个ReactE ...

  6. js 随机星星 document.createElement(); setAttribute()

    js 随机星星 document.createElement(); setAttribute() <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1. ...

  7. JS中document.createElement()用法及注意事项

    今天处理了一个日期选择器的ie和ff的兼容问题,本来这种情况就很难找错误,找了好久才把错误定位到js中创建元素的方法document.createElement(),这个方法在ie下支持这样创建元素 ...

  8. js 元素Dom新建并插入页面createElement

    纯js var o = document.createElement('script'); o.type = 'text/template'; o.id = 'demo'; document.docu ...

  9. js document.createElement()的用法 (转)

    document.createElement()的用法 分析代码时,发现自己的盲点--document.createElement(),冲浪一番,总结了点经验. document.createElem ...

随机推荐

  1. 窗体位置设置StartPosition属性

    有如下选项,分别含义如下: CenterParent                    窗体在其父窗体中居中.      CenterScreen                    窗体在当前 ...

  2. 提高SQL查询效率的常用方法

    提高SQL查询效率的常用方法 (1)选择最有效率的表名顺序(只在基于规则的优化器中有效): Oracle的解析器按照从右到左的顺序处理FROM子句中的表名,FROM子句中写在最后的表(基础表 driv ...

  3. ASP.NET工具

    每个开发人员现在应该下载的十种必备工具 发布日期: 7/20/2004 | 更新日期: 7/20/2004 本文自发布以来已经增加了新信息. 请参阅下面的编辑更新. 本文讨论: • 用于编写单元测试的 ...

  4. Opencv 的数据结构

    opencv的基本数据结构 结构 成员 意义 CvPoint int x,y 图像中的点 CvPoint2D32f float x,y 二维空间中的点 CvPoint3D32f float x,y,z ...

  5. Cocos2d-x第一个坑,NDK 编译环境

    这些天搭建windows cocos2d-x的环境,基本上崩溃到死.目前好转.终于可以编译通过: 生成模板工程:在cmd下进入cocos2d-x的主目录,D:\Android\cocos2d-x-2. ...

  6. 一些shell脚本实例

    在群里也混了不少时间了.总结一些实例 #统计QQ消息里面某个用户改名字的记录# awk -f# 聊改名字记录#特殊例子 例如#2013-11-28 9:23:56 北京-AA-Vip<12345 ...

  7. WPF中Image控件绑定到自定义类属性

    首先我们定义一个Student类,有ID,Name,Photo(保存图片路径). using System; using System.Collections.Generic; using Syste ...

  8. nginx+php-fpm 502 bad gateway

    输出日志配置: http://blog.csdn.net/wzy_1988/article/details/8486888 解决方案: http://www.cnblogs.com/jackluo/p ...

  9. 如何将word中上下两行文字对齐?

    一.问题来源及描述 本科毕设的时候积累的问题,整理如下. 红头文件下面的署名,上下要对齐. 二.解决办法 经验证,第一次拉标尺要把标尺放在第一行的光标处,为了换行后,再次enter,tab后到与上一行 ...

  10. [转]LINQ操作数据库

    查询表达式(LINQ)简介 C#3.0新语特性和改进,这些新特性在我们编写程序时为我们提供了非常大的帮助.从这篇开始,我们开始一起来探讨LINQ. LINQ是Language Integrated Q ...