title: JQuery get multiple values in divs
body: <p>I need to get values of different divs. I have 18 choices. When I select a div the class of the div becomes <code>.sm-select</code> through JS code. I can select a maximum of 4 divs and I want to get the values of the divs like: "value 1, value 4, value 6, value 12", and store them in a hidden input field. The values are text strings.</p>
  
  <p>However, presently I have only the first one when I use ".attr('value')" with my code and I display it in a input type text to test it.</p>
  
  <p>Can someone may enlighten me how I can do this? Thank you. </p>
  
  <p>My HTML : </p>
  
  <pre><code>&lt;div class="col-xs-6 sm-6"&gt;
      &lt;div class="decale sm-envies envie" value="Expo"&gt;
          &lt;p&gt;Expo&lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="col-xs-6 sm-6"&gt;
      &lt;div class="decale sm-envies envie" value="Extrême"&gt;
          &lt;p&gt;Extrême&lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="col-xs-6 sm-6"&gt;
      &lt;div class="decale sm-envies envie" value="Spa"&gt;
          &lt;p&gt;Spa&lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="col-xs-6 sm-6"&gt;
      &lt;div class="decale sm-envies envie" value="Nature"&gt;
          &lt;p&gt;Nature&lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="col-md-12 whichenvie"&gt;
      &lt;input type="text"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My JS: </p>
  
  <pre><code>$(function(){
      $('.sm-envies').each(function() {
          $(this).click(function (){
              var Envie = $('.sm-select').attr('value');
              $( ".whichenvie&gt;input" ).val(Envie);
          });
      });
  });
  </code></pre>