# TypeError: Failed to execute 'createElement' on 'Document':

**URL:** <https://forum.kirupa.com/t/typeerror-failed-to-execute-createelement-on-document/654438>\
**Category:** Uncategorized\
**Created:** [November 4, 2022, 11:26pm UTC](https://forum.kirupa.com/t/typeerror-failed-to-execute-createelement-on-document/654438 "2022-11-04T23:26:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vmars316](https://avatars.discourse-cdn.com/v4/letter/v/bcef8e/32.png) [@vmars316](https://forum.kirupa.com/u/vmars316)\
**Post date:** [November 4, 2022, 11:26pm UTC](https://forum.kirupa.com/t/typeerror-failed-to-execute-createelement-on-document/654438/1 "2022-11-04T23:26:57Z")

</div>

Hello & TIA ,  
Sorry , I can’t figure out what’s wrong :

```auto
<!DOCTYPE html>
    <!-- saved from url=(0089)file:///C:/drag-and-drop-ducks-master/Create-Element-P-w3s-document.body.appendChild.html -->
    <html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"></head><body>
    
    <h1>The Document Object</h1>
    <h2>The createElement() Method</h2>
    <p onclick="createElement()" id="notDemo" >Create a p element with some text:</p>
    <p id="demo" onclick="myFunction()">Click me.</p>
    
    <script>
    function myFunction() {
      document.getElementById("demo").innerHTML = "YOU CLICKED ME!";
    }
    </script>
    
    <script>
    function createElement(){
    alert("Entered function createElement(");
    const para = document.createElement("p");
    para.innerText = "This is a paragraph. id="notDemo" ";
    // Append to body:
    document.body.appendChild(para);
    alert("Ran function createElement(");
    }
    </script>
    
    </body></html>

```

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [November 5, 2022, 2:23am UTC](https://forum.kirupa.com/t/typeerror-failed-to-execute-createelement-on-document/654438/2 "2022-11-05T02:23:30Z")

</div>

Can you add more details on what you are trying to do? Also, when you run this in your browser, what do the DevTools Console show?

Information below on how to use the console, in case you need it 🙂

> **[Console Logging Basics](https://www.kirupa.com/html5/console.htm)**
>
> Go beyond silly alert statements and learn how to use the console to get a better view into what your code is doing.

---

<div class="post-metadata">

**Author:** ![vmars316](https://avatars.discourse-cdn.com/v4/letter/v/bcef8e/32.png) [@vmars316](https://forum.kirupa.com/u/vmars316)\
**Post date:** [November 5, 2022, 6:38pm UTC](https://forum.kirupa.com/t/typeerror-failed-to-execute-createelement-on-document/654438/3 "2022-11-05T18:38:22Z")

</div>

Thanks for your reply :  
1)  
I am trying to create elements that are completely indpendent of other elemenets . This is so that i can dragDrop any element without affecting the movement of other elements.  
In this I havent added the drag code yet (see below).  
The errors am gettng are:

> Create-Element-P-w3s-document.body.appendChild.html:7 Uncaught TypeError: Failed to execute ‘createElement’ on ‘Document’: 1 argument required, but only 0 presen at HTMLParagraphElement.onclick (Create-Element-P-w3s-document.body.appendChi  
> ld.html:7:44)  
> zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

1. 

I week ago or so , I posted my 1st try , but got no Repkies .  
It’s a Guitar Fretboard’ , with Round-Dots representong finger positioning .  
[https://vmars.us/Guitar/DragDrop-onDBLclick-RED-add-Table.html](https://vmars.us/Guitar/DragDrop-onDBLclick-RED-add-Table.html)  
So I deleted it .  
The problem with this version is that every time it create a new roun-dot  
it repositions all dots down 1 line , there by destroying the fingering positions .  
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz  
3)  
A few days later I chunked it down and posted my 2nd try , but got no Repies . It is a a chunked version of 1) .

So I deleted it .  
[https://vmars.us/Guitar/Guitar-onDBLclick-RED-add-Table-Need-Help.html](https://vmars.us/Guitar/Guitar-onDBLclick-RED-add-Table-Need-Help.html)  
Still the same goal as in 1):  
I am trying to create elements that are completely indpendent of other elemenets . This is so that i can dragDrop any element without affecting the movement of other elements.

Please help , Thanks

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [November 8, 2022, 3:16am UTC](https://forum.kirupa.com/t/typeerror-failed-to-execute-createelement-on-document/654438/4 "2022-11-08T03:16:34Z")

</div>

Sorry for the delay! It’s been a busy few weeks 📜

I took a look your example in #3: [Clone and Drag Multiple Elements](https://vmars.us/Guitar/Guitar-onDBLclick-RED-add-Table-Need-Help.html)

It worked for me. I didn’t see any errors in the Console. All of the items are also dragging correctly. Did you fix it, or am I missing something subtle? 🙂

Cheers,  
Kirupa
