How to append tag in javascript using createElement
2719 Views
CreateElement() and appendChild()
createElement() method to create the element in javascript then append the element to the selected element using appendChild() method of javascript.
Example
var element = document.createElement("DIV");
var textNode = document.createTextNode("JS is Good");
document.body.appendChild(element);
element.appendChild(textNode);
element.style.color = "blue";