Add, delete and manipulate DOM nodes

Here are examples taken from some of my code just to memorize common use node functions. I hope they are self-explanatory.


// Clone DOM node
var movingUrl = urlLineSPAN.cloneNode(true);
// Get Parent node
var urlList = urlLineSPAN.parentNode;
// Delete DOM Node
urlList.removeChild(urlLineSPAN);
// Add DOM node
urlAreaObj.appendChild(newNode);
// or
urlAreaObj.insertBefore(newNode, existingNode);

Comments

Popular posts from this blog

Data visualization for Roadmap Microsite (Angular and D3.js)

Conceptual design

Four tools for prototyping: Sketch, Figma, Principle, and FramerX