DOM adds element failed to execute ‘appendChild’ on ‘node’ to HTML: parameter 1 is not of type ‘node’ problem
Problem: failed to execute ‘appendChild’ on ‘node’: parameter 1 is not of type ‘node’
Cause: the parameter of appendChild is a node node, which leads to such a problem. It indicates that the current parameter is not a node, but may be a string.
For example:
In this case, DOM is a string
Solution:
var dom=document.createElement('p'); dom.className='book'; dom.innerHTML='hello world'; document.body.appendChild(dom);
At this point, the DOM is node.
If the added element is a string, create a node using document. Createtextnode().
var dom=document.createTextNode('hello world');
Effect in HTML:
Similar Posts:
- [Solved] DOM adds elements to HTML Error: Failed to execute ‘appendChild’ on ‘Node’: parameter 1 is not of typ…
- SyntaxError: missing ; Problem record of before statement
- Difference between normalize space (.) and normalize space (text ()) in XPath
- [Solved] WebGL Error: uncaught referenceerror unitymodule is not defined
- Document.body.clientheight cannot get the browser page height correctly
- [How to Solve] Cannot set property ‘onclick’ of null
- document.body.scrollTop or document.documentElement.scrollTop
- [Solved] Exception in thread “main” java.util.ConcurrentModificationException
- Always report uncaught error:[$ injector:modulerr ]Solutions to errors
- [Solved] Chrome Browser uploads files for a long time interrupts and reports an error: net :: ERR_NETWORK_IO_SUSPENDED