I'm trying to use the text inside the first div of an element as the CSS color value on a different element. Here's the code I've come up with so far:
<style>
  h1.page-title {
    color: red !important;
  }    
</style>
<div id="field">
  <div style="font-size:0;">#666!important</div>
  <div style="font-size:0;">second div</div>
</div>
<h1 class="page-title">hello</h1>
<script>
$(function() {
  var x = $("#field div:first").text();
  $("h1.page-title").css("color", x);
});
</script>
So far the Javascript/jQuery code doesn't seem to be working for me, but I don't know why. Is there any way to accomplish this? Please keep in mind that modifying the HTML code in any way wouldn't be ideal.
Many thanks in advance.
 
    