title: JavaScript get background color in variable
body: <p>I've been trying to get a fade in and out for a background image for a site, and I have been trying to get the background color of a div into a variable, this is what I've tried:</p>
  
  <pre><code> elem = document.getElementById('nav');
   bgColor = elem.style.backgroundColor;
  </code></pre>
  
  <p>But once I try to alert the variable <code>bgColor</code> like: <code>alert(bgColor)</code> all I get alerted is empty in the text box. I've looked around on some Stack questions and I've tried everything that is told there and it doesn't seem to put the physical color into a variable.</p>