title: Check if event.target has Children
body: <pre class="lang-html prettyprint-override"><code> &lt;h1&gt;This is my Puzzle&lt;/h1&gt;
  &lt;h3&gt;by Julian Blaschke &lt;/h3&gt;
  &lt;h4 id ="result"&gt;Its wrong&lt;h4&gt;
  
  &lt;table&gt;
    &lt;tr&gt;
      &lt;th&gt;Puzzle&lt;/th&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
   &lt;td&gt;&lt;div id="dropdiv1" ondrop="drop(event)" ondragover="allowDrop(event)"&gt;&lt;/div&gt;&lt;/td&gt;
   &lt;td&gt;&lt;div id="dropdiv2" ondrop="drop(event)" ondragover="allowDrop(event)"&gt;&lt;/div&gt;&lt;/td&gt;
   &lt;td&gt;&lt;div id="dropdiv3" ondrop="drop(event)" ondragover="allowDrop(event)"&gt;&lt;/div&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
   &lt;td&gt;&lt;div id="dropdiv4" ondrop="drop(event)" ondragover="allowDrop(event)"&gt;&lt;/div&gt;&lt;/td&gt;
   &lt;td&gt;&lt;div id="dropdiv5" ondrop="drop(event)" ondragover="allowDrop(event)"&gt;&lt;/div&gt;&lt;/td&gt;
   &lt;td&gt;&lt;div id="dropdiv6" ondrop="drop(event)" ondragover="allowDrop(event)"&gt;&lt;/div&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
   &lt;td&gt;&lt;div id="dropdiv7" ondrop="drop(event)" ondragover="allowDrop(event)"&gt;&lt;/div&gt;&lt;/td&gt;
   &lt;td&gt;&lt;div id="dropdiv8" ondrop="drop(event)" ondragover="allowDrop(event)"&gt;&lt;/div&gt;&lt;/td&gt;
   &lt;td&gt;&lt;div id="dropdiv9" ondrop="drop(event)" ondragover="allowDrop(event)"&gt;&lt;/div&gt;&lt;/td&gt;
    &lt;/tr&gt;
   &lt;/table&gt;
  
  
  
  &lt;table style="width:100%"&gt;
    &lt;tr&gt;
      &lt;th&gt;Puzzle&lt;/th&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;img id="1" src="splitted\1.png" draggable="true" ondragstart="drag(event)" width="100" height="80"&gt;&lt;/td&gt;
   &lt;td&gt;&lt;img id="2" src="splitted\2.png" draggable="true" ondragstart="drag(event)" width="100" height="80"&gt;&lt;/td&gt;
   &lt;td&gt;&lt;img id="3" src="splitted\3.png" draggable="true" ondragstart="drag(event)" width="100" height="80"&gt;&lt;/td&gt;
   &lt;td&gt;&lt;img id="4" src="splitted\4.png" draggable="true" ondragstart="drag(event)" width="100" height="80"&gt;&lt;/td&gt;
   &lt;td&gt;&lt;img id="5" src="splitted\5.png" draggable="true" ondragstart="drag(event)" width="100" height="80"&gt;&lt;/td&gt;
   &lt;td&gt;&lt;img id="6" src="splitted\6.png" draggable="true" ondragstart="drag(event)" width="100" height="80"&gt;&lt;/td&gt;   
   &lt;td&gt;&lt;img id="7" src="splitted\7.png" draggable="true" ondragstart="drag(event)" width="100" height="80"&gt;&lt;/td&gt;
   &lt;td&gt;&lt;img id="8" src="splitted\8.png" draggable="true" ondragstart="drag(event)" width="100" height="80"&gt;&lt;/td&gt;
   &lt;td&gt;&lt;img id="9" src="splitted\9.png" draggable="true" ondragstart="drag(event)" width="100" height="80"&gt;&lt;/td&gt;
  
    &lt;/tr&gt;
   &lt;/table&gt;
  </code></pre>
  
  
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function allowDrop(ev) {
      ev.preventDefault();
  }
  
  function drag(ev) {
      ev.dataTransfer.setData("text", ev.target.id);
  }
  
  function drop(ev) {
   ev.preventDefault();
   var data = ev.dataTransfer.getData("text");
    
  if(ev.target.firstChild == null)
       ev.target.appendChild(document.getElementById(data));
  
       
  }
  
  function checkifright(){
  document.getElementById("result").innerHTML =(document.getElementById("dropdiv1").firstChild.src);
  if (document.getElementById("dropdiv1").firstChild.src == "file:///C:/Users/Julian/Desktop/SCHULE%20201617/BSD/HTML_JavaSccript/Blaschke_Puzzle/splitted/1.png")
  if (document.getElementById("dropdiv2").firstChild.src == "file:///C:/Users/Julian/Desktop/SCHULE%20201617/BSD/HTML_JavaSccript/Blaschke_Puzzle/splitted/2.png")
    document.getElementById("result").innerHTML ="right";
  
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>How can I check in the if statment if the target has already a child.In my if it appends two times a picture but it should only be added one time...</p>
  
  <p>I don't undestand why. It should work fine but it appends two times the same picture the 3 time it does not go in the if statment</p>