Cannot get div element by id to display gif in internet explorer <p>I am trying to make a .gif image display in a loading window to alert my user that loading is underway, quite simple. I was doing it using only css and <code>background</code> property like this:</p> <p>/<em>background: url(ajax-loader.gif) no-repeat center #fff;</em>/</p> <p>but my .gif was not loading in internet explorer. So I've made a research and found <a href="http://stackoverflow.com/questions/780560/animated-gif-in-ie-stopping">this</a> and, based on J.Davies's solution, I have implemented this instead in my js file:</p> <pre><code>function ShowProgress() { if (!spinnerVisible) { $('div#layer').fadeIn("fast"); $('div#spinner').fadeIn("fast"); spinnerVisible = true; var pb = $('#spinner'); pb.innerHTML = '&lt;img src="./ajax-loader.gif" width=200 height=40/&gt;'; pb.style.display = ""; } } </code></pre> <p>My problem is that it works still in chrome, but I get a crash in internet explorer saying that it pb is undefined. Is there a specificity on how to work with jquery and internet explorer? For information, here's my display:</p> <pre><code>&lt;div id="body"&gt; @RenderSection("featured", false) &lt;section class="content-wrapper main-content clear-fix"&gt; &lt;section&gt; @Html.Partial("MessageDisplay") &lt;/section&gt; &lt;div id="layer"&gt;&lt;/div&gt; &lt;div id="spinner"&gt; Loading, please wait... &lt;/div&gt; @RenderBody() &lt;/section&gt; &lt;/div&gt; </code></pre> <p>And the css saying that spinner and layer div are hidden:</p> <pre><code>div#spinner { display: none; width: 300px; height: 300px; position: fixed; top: 40%; left: 45%; /*background: url(ajax-loader.gif) no-repeat center #fff;*/ text-align: center; padding: 10px; font: normal 16px Tahoma, Geneva, sans-serif; border: 1px solid #666; margin-left: -50px; margin-top: -50px; z-index: 2; overflow: auto; } div#layer { display: none; width: 100%; height: 100%; position: fixed; top: 0; left: 0; background-color: #a4a3a3; background-color: rgba(164, 163, 163, 0.5); z-index: 1; overflow: auto; -moz-opacity: 0.5 } </code></pre>