title: Applying background color to div after append method
body: <p>I'm trying to create a dynamic color <em>bookmarker</em> just to practice jQuery, however, I'm having an issue using the append method to make a new div and applying a CSS background method to apply the text of the div (the input) as the color of the individual div. My problem is not getting the background color applied. I'm not quite sure what I'm doing wrong or why my <code>.css()</code> method isn't working.</p>
  <pre><code>var colorIn = $(&quot;#materialColorInput&quot;);
  var matDes = $(&quot;.material-design&quot;);
  
  colorIn.keypress(function (event) {
    if (event.which === 13) {
      var inVal = colorIn.val();
      var color = $(&quot;.color&quot;);
      colorIn.val(&quot;&quot;);
      function addBackColor() { 
          $(&quot;this&quot;).css('background-color', $(this).text())
      };
      var addDiv = $('&lt;div onload=&quot;addBackColor()&quot;&gt;' +inVal+ '&lt;/div&gt;').addClass(&quot;color&quot;);
      matDes.append(addDiv);
    }
  });
  </code></pre>
  <p>I've also made a pen for it:
  <a href="http://codepen.io/Aricha03/pen/KzqXmr" rel="nofollow noreferrer">http://codepen.io/Aricha03/pen/KzqXmr</a></p>