title: Add element to a div with javascript
body: <p>I want to add an element (child, div) to a mother-div, that already has one or more children. I made a script for this action but when I execute the script I am not able to manipulate style attributes afterwards. So I assume I did something wrong in my creation-script. I also added a console message (end of the script) and that also indicates there are no style attributes filled in at the new div. So, please could someone indicate what the reason is...</p>
  <p>As I am quite new to javascript I assume the reason is quite simple. But although I checked many other questions and solutions, I do not get the proper solution for my issue. I think it should be in appendChild or insertBefore.</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 preparevideo(videonaam, titel) {
    // add a div to the video-div
    const nieuwetitel = document.createElement("div");
    // give the new div an id so it will be unique
    nieuwetitel.id = videonaam + '-id';
    // give the div a class for the markup
    nieuwetitel.className = 'page-roel-video-titel';
    // create the text in the div
    const textnode = document.createTextNode(titel);
    // add the textnode to the div
    nieuwetitel.appendChild(textnode);
    // find the element where the new div should be added to  
    let videomodule = document.getElementById(videonaam);
    // and finally add the new div to the video-div, as the first child
    videomodule.insertBefore(nieuwetitel, videomodule.children[0]);
  
    console.log('-------after adding div------');
    console.log('-------complete style of titleblock------');
    console.log(document.getElementById(videonaam + '-id').style);
    console.log('prepare video afgerond');
  }
  preparevideo("naam1","Eerste video");</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="naam1"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>