So, I did not think that this would that complicated but I cannot figure it out myself.
I preload images in the <head>
with JS.
//PRELOAD THE IMAGES
original = new Image(698, 360);
original.src = "imagenes_png/bosque_mapa.png";
...
Then I want to insert the preloaded images ito a div tag
with the name test, also with JS.
//Thats in the head aswell
document.getElementById('test').appendChild(original)
That is my div tag
in the body
<div id="test"> testext</div>
That does not work though. The div
is still testext
For people with the same issue:
Put the
document.getElementById('test').appendChild(original)
into here
$(document).ready(function() { /* code here */ });
$(document).ready(function() {document.getElementById('test').appendChild(original)});
Why? Read the comment of David Thomas and follow the posted link!
**Note: That solution requieres jQuery which can be loaded like this:
<!-- LINK ZU JQUERY ONLINE-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>