title: Removing external js file dynamically
body: <p>I am trying to remove the js file on mouseclick. I am referring to www.javascriptkit.com/javatutors/loadjavascriptcss2.shtml  for removing
  But its not working for me
  This is my corresponding code</p>
  
  <p>HTML part:</p>
  
  <pre><code>&lt;div id="dropdownlist" style="position:absolute;z-index:102;"&gt;
                    &lt;a href="#" onclick="DisplayDropdownSelectedPage('blog')"&gt;BLOG&lt;/a&gt;&lt;br/&gt;&lt;a href="#" onclick="DisplayDropdownSelectedPage('careers')"&gt;CAREERS&lt;/a&gt;&lt;br/&gt;&lt;a href="#" onclick="DisplayDropdownSelectedPage('whistleblower')"&gt;WHISTLE BLOWSER&lt;/a&gt;&lt;br/&gt;&lt;a href="#" onclick="DisplayDropdownSelectedPage('disclaimer')"&gt;DISCLAIMER&lt;/a&gt;&lt;br/&gt;&lt;a href="#" onclick="DisplayDropdownSelectedPage('sitemap')"&gt;SITEMAP&lt;/a&gt;&lt;br/&gt;&lt;a href="#" onclick="DisplayDropdownSelectedPage('feedback')"&gt;FEEDBACK&lt;/a&gt;&lt;br/&gt;
                  &lt;/div&gt;
  </code></pre>
  
  <p>JS part:</p>
  
  <pre><code>function removejscssfile(filename, filetype){
   var targetelement=(filetype=="js")? "script" : (filetype=="css")? "link" : "none" //determine element type to create nodelist from
   var targetattr=(filetype=="js")? "src" : (filetype=="css")? "href" : "none" //determine corresponding attribute to test for
   var allsuspects=document.getElementsByTagName(targetelement)
   for (var i=allsuspects.length; i&gt;=0; i--){ //search backwards within nodelist for matching elements to remove
    if (allsuspects[i] &amp;&amp; allsuspects[i].getAttribute(targetattr)!=null &amp;&amp; allsuspects[i].getAttribute(targetattr).indexOf(filename)!=-1)
     allsuspects[i].parentNode.removeChild(allsuspects[i]) //remove element by calling parentNode.removeChild()
   }
  }
  
  function DisplayDropdownSelectedPage(dropdownname)
  {
      var width=$(window).width();
      var height=$(window).height();
      var top=document.getElementById("globelHead").offsetHeight;
      var animateheight=(height-top);
      var animatewidth=(width/2);
      var shiftright=(-(animatewidth)+"px");
      if(dropdownname=="blog")
      {
          removejscssfile("myscript.js", "js")
          $("#Blog").css({"width":animatewidth+"px","height":animateheight,"right":shiftright,"top":top});
          $("#Blog").show().animate({right:'0%'},1200);
          $("#Careers").hide();
          $("#WhistleBlower").hide();
          $("#Disclaimer").hide();
          $("#SiteMap").hide();
          $("#Feedback").hide();
  
      }
      else if(dropdownname=="careers")
      {
          removejscssfile("myscript.js", "js")
          $("#Blog").hide();
          $("#Careers").css({"width":animatewidth+"px","height":animateheight,"right":shiftright,"top":top});
          $("#Careers").show().animate({right:'0%'},1200);
          $("#WhistleBlower").hide();
          $("#Disclaimer").hide();
          $("#SiteMap").hide();
          $("#Feedback").hide();
      }
      else if(dropdownname=="whistleblower")
      {
          removejscssfile("myscript.js", "js")
          $("#Blog").hide();
          $("#Careers").hide();
          $("#WhistleBlower").css({"width":animatewidth+"px","height":animateheight,"right":shiftright,"top":top});
          $("#WhistleBlower").show().animate({right:'0%'},1200);
          $("#Disclaimer").hide();
          $("#SiteMap").hide();
          $("#Feedback").hide();
      }
      else if(dropdownname=="disclaimer")
      {   
          removejscssfile("myscript.js", "js")
          $("#Blog").hide();
          $("#Careers").hide();
          $("#WhistleBlower").hide();
          $("#Disclaimer").css({"width":animatewidth+"px","height":animateheight,"right":shiftright,"top":top});
          $("#Disclaimer").show().animate({right:'0%'},1200);
          $("#SiteMap").hide();
          $("#Feedback").hide();
  
      }
      else if(dropdownname=="sitemap")
      {
  
          $("#Blog").hide();
          $("#Careers").hide();
          $("#WhistleBlower").hide();
          $("#Disclaimer").hide();
          $("#SiteMap").css({"width":animatewidth+"px","height":animateheight,"right":shiftright,"top":top});
          $("#SiteMap").show().animate({right:'0%'},1200);
          $("#Feedback").hide();
  
      }
      else if(dropdownname=="feedback")
      {
          $("#Blog").hide();
          $("#Careers").hide();
          $("#WhistleBlower").hide();
          $("#Disclaimer").hide();
          $("#SiteMap").hide();
          $("#Feedback").css({"width":animatewidth+"px","height":animateheight,"right":shiftright,"top":top});
          $("#Feedback").show().animate({right:'0%'},1200);
      }
  }
  </code></pre>