I'm having an issue trying to create three elements (parent and one child) where the third element, an <a>
tag, is not appending to modalChild
even though it's being created correctly.
modal = document.createElement("div");
modal.className = "parent";
modalChild = document.createElement("div");
modalChild.className = "child";
btnClose = document.createElement("a");
btnClose.className = "btnClose";
btnClose.textContent = "X";
modal.appendChild(modalChild);
modalChild.appendChild(btnClose);
document.body.appendChild(modal);
modal.style.display = "flex";
modalChild
is getting appended to modal properly, but btnClose
is not attaching to modalChild
. Can someone help me identify what's wrong with the code?