Using innerHTML on a node:
var node=document.getElementById(‘node-id’);
node.innerHTML(‘<p> some dynamic html</p>’);
Using DOM methods:
var node=document.getElementById(‘node-id’);
var newNode=document.createElement(‘p’);
newNode.appendChild(document.createTextNode(‘Your dynamic html’));
node.appendChild(newNode);
Utilizing the DOM API strategies may be the perfectionist approach to do stuff, yet innerHTML has been demonstrated to be a lot quicker and is utilized in the engine in JavaScript libraries like jQuery.
Want to full stack development? Check out the full stack developer course from Intellipaat.