createElement()
noun
say it: “kree-AYT EL-uh-ment” /kriˈeɪt ˈɛləmənt/
A DOM method that makes a new element, ready to be filled in and added to the page.
What is createElement() in JavaScript?
createElement() — A method on document that makes a new element from a tag name. It isn't on the page until you add it with appendChild() or append().
const item = document.createElement("li");
item.textContent = "Chai";
document.getElementById("cart").appendChild(item);
In a sentence
- “I used createElement("li") to make a new item for the cart list.”
Level: Apprentice · More JavaScript terms at this level
Updated