[Solved] DOM adds elements to HTML Error: Failed to execute ‘appendChild’ on ‘Node’: parameter 1 is not of typ…

question: failed to execute ‘appendChild’ on ‘node’: parameter 1 is not of type ‘node’

reason: the parameter of appendChild is node. This problem indicates that the current parameter is not node, it may be a string

For example:

DOM is a string


var dom=document.createElement('p');
dom.innerHTML='hello world';

In this case, DOM is node

If the added element is a string, use document. Createtextnode() to create the node

var dom=document.createTextNode('hello world');

Similar Posts: