I have this piece
var inviteSection = document.getElementByClassName("invitedFriends");
var friend = document.createElement("div").class = "friend";
var mail = document.createElement("p").class = "mail";
var span = document.createElement("span").class = "status accepted";
function main() {
inviteSection.appendChild(friend);
friend.appendChild(mail);
friend.appendChild(span);
}
main();
When I run this chrome console it says 'Uncaught TypeError: inviteSection.appendChild is not a function' Is there any fix for this please help me guys!
inviteSection
is a NodeList not a dom element referencegetElementsByClassName
. Plural.document.createElement("p").className = "mail"
. Also, where you havevar mail = document.createElement("p").class = "mail";
then the value of the variable mail is the string"mail"
. Was that intended?