title: How to set data-* attribute of checked radio to class of another element using jquery?
body: <p>How do I take the <code>data-attribute</code> of a checked radio button and output it inside the class attribute of a different element?</p>
  
  <p>Please take a look at the example:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>body{
    background: #eee;
  }  
  
  .box{
    background: #000;
    margin: 40px;
    width: 200px;
    height: 200px;
  }
  
  .box.black{
    background: #000;
  }
  
  .box.white{
    background: #fff;
  }
  
  .box.green{
    background: #00d300;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;input data-color="black" id="radio1" type="radio" name="radio" checked&gt;
  &lt;label for="radio1"&gt;Black&lt;/label&gt;
  &lt;input data-color="white" id="radio2" type="radio" name="radio"&gt;
  &lt;label for="radio2"&gt;White&lt;/label&gt;
  &lt;input data-color="green" id="radio3" type="radio" name="radio"&gt;
  &lt;label for="radio3"&gt;Green&lt;/label&gt;
  
  &lt;div class="box"&gt;&lt;/div&gt;
  &lt;div class="box"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>