daniel-plewinski
9/2/2017 - 5:15 AM

Javascript Tworzenie nowych elementów, Creating New Elements

Javascript Tworzenie nowych elementów, Creating New Elements

var newDiv = document.createElement("div");
var toClone =
document.querySelector('#foo');
var newDiv = toClone.cloneNode(true); // true = deep

 
var fooElement = document.querySelector('#foo');
var newBar = document.createElement("div");
fooElement.appendChild(newBar);
var newBuz = document.createElement("h1");
fooElement.insertBefore(newBuz, newBar);
var newBuz = document.createElement("p");
fooElement.replaceChild(newBuz, newBar);

var toDelete =document.querySelector('#bar');
toDelete.parentElement.removeChild(toDelete);