<p>Here I modified you code and now working solution is,</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>&lt;script type="text/javascript"&gt;
  $(".file a").on("click",function(){
    $(this).text('Loading...'); // do your UI thing here
    e.preventDefault();
    var destination = this.href;
    setTimeout(function() {
        window.location = destination;
    },100);
    $('&lt;iframe&gt;').hide().appendTo('body').load(function() {
        window.location = destination;
    }).attr('src', destination);
});
&lt;/script&gt;</code></pre>
<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;body style="color: black;  background-color: #EFF6E4;font-family: myFirstFont; "&gt;
  
  &lt;ol class="tree"&gt;
    
    &lt;li&gt;
      &lt;label for="folder2"&gt;First Semestar&lt;/label&gt; &lt;input type="checkbox" id="folder2" /&gt; 
      &lt;ol&gt;
        
        &lt;li&gt;
          &lt;label for="subfolder2"&gt;Electronics&lt;/label&gt; &lt;input type="checkbox" id="subfolder2" /&gt; 
          &lt;ol&gt;
           &lt;li class="file"&gt;

            &lt;a href="
https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGUm9fLVd2dVpuQ28" &gt;Bogart Chapter 8 Solutions &lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGbUw2Y2RzeXQyYTQ"&gt;Bogart Digital to Analog Chapter&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGSjM4VDNuZ180VWM
"&gt;An Introduction to Error Analysis &lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGbUw2Y2RzeXQyYTQ"&gt;Basic of Electronics&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGdkNWZHJBbUY4WGM"&gt;Solution from Bogart Book&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGUTdvN29GU0VoY0U"&gt;Least Square Solutions&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGeTY5RmtMLXFoWWs"&gt;Estimation of Error&lt;/a&gt;&lt;/li&gt;
            
          &lt;/ol&gt;
        &lt;/li&gt;
        &lt;li&gt;
          &lt;label for="subfolder3"&gt;Mathematical Physics&lt;/label&gt; &lt;input type="checkbox" id="subfolder3" /&gt; 
          &lt;ol&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGd2NCWm5iMmluWVU"&gt;Tutorial One and Two&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGVFFwc1VTeGVtVTA"&gt;Tutorial One and Two II&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGOFBkTmRLc1hVN1E"&gt;Tutorial 4&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGeFN2Q2N6QjNnSTQ"&gt;Tutorial 3&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGNEE4ZG9zT2NKSG8"&gt;Curvature and Torison Curves&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGdmJLVUFxMEdZU2M"&gt;Arfken Solution&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGRmdjUVpLaXN1UGM"&gt;Schaum's tensor Analysis&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGbmEwM2ZrclF5ODA"&gt;George B. Arfken, Hans J. Weber, Manual_ Mathematical Methods for Physicists&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGRmdjUVpLaXN1UGM"&gt;Schaum's Tensor Calculus&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGZjg1MDVYRWI0TW8"&gt;Vector space and Eigen Value&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGcmMwT1FGUGFod0E"&gt;Vector in Functional space&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGVzVtWndjVktwTDg"&gt;Vector funtional Space&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGdHFCbUVnOEp6RDQ"&gt;Orothonormal Basis&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGbG9SQXd2RE1DWUk"&gt;Linear Vector Space&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGemNnQ3ZJZkhBV3c"&gt;Linear Transformation&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGWllDS0pBVFpQemc"&gt;Change of Basis&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGZzZ2blRkclhhczg"&gt;Operators&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGdU9udFd5UzBZSVk"&gt;Operators&lt;/a&gt;&lt;/li&gt;
          &lt;/ol&gt;
        &lt;/li&gt;
        &lt;li&gt;
          &lt;label for="subfolder4"&gt;Quantum Mechanics&lt;/label&gt; &lt;input type="checkbox" id="subfolder4" /&gt; 
          &lt;ol&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGZllRR2pvTzdYVU0"&gt;Binil Sir Lecture ( 1-5 ) From Quantum Spin&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGcWFVcTdvejRoQjQ"&gt;Schaum's Series&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGeTBmSE94aDB5bEU"&gt;Basis and Dimension&lt;/a&gt;&lt;/li&gt;
            
          &lt;/ol&gt;
        &lt;/li&gt;
        &lt;li&gt;
          &lt;label for="subfolder5"&gt;Classical Mechanics&lt;/label&gt; &lt;input type="checkbox" id="subfolder5" /&gt; 
          &lt;ol&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGVEFmU0V4bGNiR1k"&gt;Non-Linear Dynamics&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGUkdOaEg0Mmdaa00"&gt;Goldstein Chp 8 Solutions ( BG Sir Homework )&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGZmVEZ2N1aEVwOE0"&gt;Goldstein Chp 9 Solutions Handwritten ( BG Sir Homework )&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGT0pfWnhXZFNIQmc"&gt;Goldstein Chp 9 Solutions (BG Sir Homework)&lt;/a&gt;&lt;/li&gt;
             &lt;li class="file"&gt;&lt;a href="https://archive.org/download/arxiv-math-ph0012051/math-ph0012051_jp2.zip"&gt;Operator formalism of quantum mechanics&lt;/a&gt;&lt;/li&gt;
            
          &lt;/ol&gt;
        &lt;/li&gt;
        
    
  

&lt;/body&gt;
&lt;/html&gt;</code></pre>
</div>
</div>
</p>

<p>But It won't return to the original text and stuck forever on Loading.</p>
Display loading text or image when href link is clicked inside div of html page
<p>I'm making an website with tons of Notes and Books to Download. I would Like to show any image or any Text when Link is Download link is clicked and when request is complete and file starts to Download , then remove the image or Loading Text.</p>

<p>I've gone through lots of forums but couldn't find any solution.</p>

<p>Here is the html File of mine</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;body style="color: black;  background-color: #EFF6E4;font-family: myFirstFont; "&gt;
  
  &lt;ol class="tree"&gt;
    
    &lt;li&gt;
      &lt;label for="folder2"&gt;First Semestar&lt;/label&gt; &lt;input type="checkbox" id="folder2" /&gt; 
      &lt;ol&gt;
        
        &lt;li&gt;
          &lt;label for="subfolder2"&gt;Electronics&lt;/label&gt; &lt;input type="checkbox" id="subfolder2" /&gt; 
          &lt;ol&gt;
           &lt;li class="file"&gt;

            &lt;a href="
https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGUm9fLVd2dVpuQ28" &gt;Bogart Chapter 8 Solutions &lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGbUw2Y2RzeXQyYTQ"&gt;Bogart Digital to Analog Chapter&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGSjM4VDNuZ180VWM
"&gt;An Introduction to Error Analysis &lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGbUw2Y2RzeXQyYTQ"&gt;Basic of Electronics&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGdkNWZHJBbUY4WGM"&gt;Solution from Bogart Book&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGUTdvN29GU0VoY0U"&gt;Least Square Solutions&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGeTY5RmtMLXFoWWs"&gt;Estimation of Error&lt;/a&gt;&lt;/li&gt;
            
          &lt;/ol&gt;
        &lt;/li&gt;
        &lt;li&gt;
          &lt;label for="subfolder3"&gt;Mathematical Physics&lt;/label&gt; &lt;input type="checkbox" id="subfolder3" /&gt; 
          &lt;ol&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGd2NCWm5iMmluWVU"&gt;Tutorial One and Two&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGVFFwc1VTeGVtVTA"&gt;Tutorial One and Two II&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGOFBkTmRLc1hVN1E"&gt;Tutorial 4&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGeFN2Q2N6QjNnSTQ"&gt;Tutorial 3&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGNEE4ZG9zT2NKSG8"&gt;Curvature and Torison Curves&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGdmJLVUFxMEdZU2M"&gt;Arfken Solution&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGRmdjUVpLaXN1UGM"&gt;Schaum's tensor Analysis&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGbmEwM2ZrclF5ODA"&gt;George B. Arfken, Hans J. Weber, Manual_ Mathematical Methods for Physicists&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGRmdjUVpLaXN1UGM"&gt;Schaum's Tensor Calculus&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGZjg1MDVYRWI0TW8"&gt;Vector space and Eigen Value&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGcmMwT1FGUGFod0E"&gt;Vector in Functional space&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGVzVtWndjVktwTDg"&gt;Vector funtional Space&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGdHFCbUVnOEp6RDQ"&gt;Orothonormal Basis&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGbG9SQXd2RE1DWUk"&gt;Linear Vector Space&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGemNnQ3ZJZkhBV3c"&gt;Linear Transformation&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGWllDS0pBVFpQemc"&gt;Change of Basis&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGZzZ2blRkclhhczg"&gt;Operators&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGdU9udFd5UzBZSVk"&gt;Operators&lt;/a&gt;&lt;/li&gt;
          &lt;/ol&gt;
        &lt;/li&gt;
        &lt;li&gt;
          &lt;label for="subfolder4"&gt;Quantum Mechanics&lt;/label&gt; &lt;input type="checkbox" id="subfolder4" /&gt; 
          &lt;ol&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGZllRR2pvTzdYVU0"&gt;Binil Sir Lecture ( 1-5 ) From Quantum Spin&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGcWFVcTdvejRoQjQ"&gt;Schaum's Series&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGeTBmSE94aDB5bEU"&gt;Basis and Dimension&lt;/a&gt;&lt;/li&gt;
            
          &lt;/ol&gt;
        &lt;/li&gt;
        &lt;li&gt;
          &lt;label for="subfolder5"&gt;Classical Mechanics&lt;/label&gt; &lt;input type="checkbox" id="subfolder5" /&gt; 
          &lt;ol&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGVEFmU0V4bGNiR1k"&gt;Non-Linear Dynamics&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGUkdOaEg0Mmdaa00"&gt;Goldstein Chp 8 Solutions ( BG Sir Homework )&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGZmVEZ2N1aEVwOE0"&gt;Goldstein Chp 9 Solutions Handwritten ( BG Sir Homework )&lt;/a&gt;&lt;/li&gt;
            &lt;li class="file"&gt;&lt;a href="https://drive.google.com/uc?export=download&amp;id=0B2j3ckof7nFGT0pfWnhXZFNIQmc"&gt;Goldstein Chp 9 Solutions (BG Sir Homework)&lt;/a&gt;&lt;/li&gt;
             &lt;li class="file"&gt;&lt;a href="https://archive.org/download/arxiv-math-ph0012051/math-ph0012051_jp2.zip"&gt;Operator formalism of quantum mechanics&lt;/a&gt;&lt;/li&gt;
            
          &lt;/ol&gt;
        &lt;/li&gt;
        
    
  

&lt;/body&gt;
&lt;/html&gt;</code></pre>
</div>
</div>
</p>

<p>Any help would be much much appreciated.</p>