Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

replace element javascript

// select the element that will be replacedvar el = document.querySelector('div');
// <a href="/javascript/manipulation/creating-a-dom-element-51/">create a new element</a> that will take the place of "el"var newEl = document.createElement('p');newEl.innerHTML = '<b>Hello World!</b>';
// replace el with newELel.parentNode.replaceChild(newEl, el);
Source by plainjs.com #
 
PREVIOUS NEXT
Tagged: #replace #element #javascript
ADD COMMENT
Topic
Name
8+5 =