While studying the Document object model today, I faced a problem of appending a newly created child on the document object directly, here is my code :
var newEl=document.createElement("textarea");
document.appendChild(newEl);
the resulted error is :
Uncaught DOMException: Failed to execute 'appendChild' on 'Node': Only one element on document allowed.
I know the solution is to either append it to document.body or document.documentElement , but I didn't find a reference pointing that the mentioned way is not correct for a specific reason.
accept my apologies for being a beginner.