title: How can I get the background colour from a style attribute as a hex value using JavaScript in IE 9?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1740700/get-hex-value-rather-than-rgb-value-using-jquery">Get hex value rather than RGB value using jQuery</a>  </p>
  </blockquote>
  
  
  
  <p>I've got a <code>&lt;span&gt;</code> like this:</p>
  
  <pre><code>&lt;span class="colour" style="background:#000000;"&gt;&lt;/span&gt;
  </code></pre>
  
  <p>In most browsers, including IE 8, I can get the hex value of the background colour like this:</p>
  
  <pre><code>$('span.colour').attr('style').match(/#[0123456789ABCDEF]{3,6}/gi);
  </code></pre>
  
  <p>However, in IE 9, <code>$('span.colour').attr('style')</code> returns the following string:</p>
  
  <pre><code>background: rgb(0, 0, 0);
  </code></pre>
  
  <p>Do I have to convert back to hex in JavaScript, or is there a way to get IE 9 to give me the hex value (i.e. the thing that's actually in the damn HTML) straight from the element?</p>