Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript create node from innerhtml

function createElement( str ) {
    var frag = document.createDocumentFragment();

    var elem = document.createElement('div');
    elem.innerHTML = str;

    while (elem.childNodes[0]) {
        frag.appendChild(elem.childNodes[0]);
    }
    return frag;
}
Comment

javascript createelement innerhtml

let div = document.querySelector('.container');

let p = document.createElement('p');
p.textContent = 'JS DOM';
div.appendChild(p);
Code language: JavaScript (javascript)
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript es6 class 
Javascript :: fetch api 
Javascript :: node require fs not found 
Javascript :: some method javascript 
Javascript :: how to create empty two dimensional array in javascript 
Javascript :: javascript auto scroll horizontal 
Javascript :: two digits number javascript 
Javascript :: javascript get tag child elements 
Javascript :: post request with data and headers 
Javascript :: clear all cookies 
Javascript :: jquery on multiple events 
Javascript :: textarea onclick select all 
Javascript :: js detect if content editable div is empty 
Javascript :: js search in object 
Javascript :: find duplicates and their count in an array javascript 
Javascript :: javascript fill 2 dimensional array 
Javascript :: get only string from html description javascript 
Javascript :: How to find unique values from an array in sorted order js 
Javascript :: react-router useNavigate 
Javascript :: javascript base64 to length 
Javascript :: replace character inside a string in JavaScript 
Javascript :: scrollintoview javascript 
Javascript :: react-bootstrap problem-install new version 
Javascript :: select the first elemnt have class in jquery 
Javascript :: Sequelize.Op; 
Javascript :: prevent refresh react 
Javascript :: javascript find the longest word in a string 
Javascript :: javascript string to array 
Javascript :: vuejs set default value for prop 
Javascript :: javascript remove object element 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =