title: Adding Button to specific div
body: <p>I want to create Buttons in a loop, depending on a value it has to create x buttons, for the beginning I'm trying to get the creation of a Button via Javascript. 
  th e button with the function has to be in one , but the button it creates has to be created in another . </p>
  
  <p>How do I get this done? </p>
  
  <p>My idea, shown below, does not work.</p>
  
  <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 createButton(context, func){
      var button = document.createElement("input");
      button.type = "button";
      button.value = "im a button";
      button.onclick = func;
      context.appendChild(button);
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>html,body { margin:0; padding: 0; }
  #inputpanel {
    width: calc(40vw - 10px);
  }
  #selectpanel {
    width: calc(20vw - 10px);
  }
  
  #inputpanel,#selectpanel {
    display: inline-block;
    box-sizing: border-box;
    height: calc(100vh - 200px);
    margin: 0;
    padding: 0;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="inputpanel"&gt;
    
   &lt;button type="button" id="createBut" onclick="createButton(document.selectpanel, function(){
      alert('it works');})"&gt;create Button&lt;/button&gt;
  &lt;/div&gt;
  
  &lt;div id="selectpanel"&gt;
  adsadasdasd&lt;br /&gt;
  asfdsdfsdfgdf
  
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thanks Adrian</p>