title: Add a Class to Body Tag: Testing Existing Javascript Solution with No Results
body: <p>I found a great piece of Javascript code <strong>(StackOverflow link: <a href="https://stackoverflow.com/questions/1283511/how-to-add-a-class-to-body-tag">How to add a class to body tag?</a>)</strong>. However, I am having trouble implementing it.</p>
  
  <p>Below is the code I'm using on a test page:</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Javascript Test&lt;/title&gt;
  &lt;meta charset="utf-8" /&gt;
  
  &lt;script type="text/javascript"&gt;
  var newClass = window.location.href;
  newClass = newClass.match(/\/[^\/]+(_|\.)[^\/]+$/);
  $(document.body).addClass(newClass);
  &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>However I do not see any class added to the body tag as a result. (Viewing Source in Safari, Chrome) I've tested with and without jQuery. </p>
  
  <p>Do you see what's wrong with the code?</p>
  
  <p>I'm working with a Behance ProSite. I can create multiple galleries, but each will have the same background because they use the same template. I need to add a unique class to the body tag so I can target each with a different CSS background property.</p>