首页 > Web开发 > 详细

js createElement

时间:2016-03-12 01:26:29      阅读:354      评论:0      收藏:0      [点我收藏+]

?

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

原文:http://www.cnblogs.com/icenter/p/5267674.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!