Load images before showing a div
<p>I have never asked anything on this forum before so I'll try to be as clear as possible.
I am trying to show a loading screen while the contents of a div is loading in my website.</p>

<p>I tried to use jQuery .load() function but it seems not to work.
It works when i use the .ready() function but i want to load all the images before to show the div.</p>

<p>So the div is hidden (style="display:none;")</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-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
&lt;div id="loading"&gt; // loading screen &lt;/div&gt;
&lt;div id="divtoshow" style="display:none;"&gt; //images and text &lt;/div&gt;

&lt;script&gt;
$("#divtoshow").load(function(){
  $("#loading").fadeOut(200);
  $("#divtoshow").fadeIn(200);
});
//if i replace load with ready it works
&lt;/script&gt;</code></pre>
</div>
</div>
</p>