title: Get IE Version + Add Class to body
body: <p>I am trying to find which version of IE people are using and adding a class to the body tag depending on which browser.</p>
  
  <p>the code i have is </p>
  
  <pre><code>if (navigator.appName == "Microsoft Internet Explorer") {
  //Set IE as true
  ie = true;
  //Create a user agent var
  var ua = navigator.userAgent;
  //Write a new regEx to find the version number
  var re = new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");
  //If the regEx through the userAgent is not null
  if (re.exec(ua) != null) {
      //Set the IE version
      ieVersion = parseInt(RegExp.$1);
  }
  
  
  }
  
  else {
      ie = false;
  }
  
  function ieTag() {
      if (ie == true) {
          if (ieVersion == 7) {
              $('body').addClass('IE7');
          }
      }
      if (ie == true) {
          if (ieVersion == 8) {
              $('body').addClass('IE8');
          }
      }
      if (ie == true) {
          if (ieVersion == 9) {
              $('body').addClass('IE9');
          }
      }
  
  }
  </code></pre>
  
  <p>and i am using this to call the function </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          //IE Version Control
          ieTag();
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>but i am only picking up IE 9 for some reason, i have had this script working before so i really dont understand whats gone wrong!!!</p>
  
  <p>i have even tried using this script </p>
  
  <pre><code>function ieTag() {
  if (ie == true) {
      $('body').addClass('IE' + ieVersion);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>but still only picking up IE9 </p>
  
  <p>I ma using IE( and the developer tools to change version (which both of these scripts has worked on before)</p>