title: toggle element, if first clicked toggle all element inside that div
body: <p>Imagine each div as a card in your hand, and you have to choose which ones to play.</p>
  
  <p>I can't change group class name nor element class name.</p>
  
  <p>RULES:</p>
  
  <ul>
  <li>if an element clicked its toggle his position &lt;-- left/right --></li>
  <li>if the first element of the group clicked all element in that group goes right --></li>
  <li>if all elements in that group are already on the right, and the first element clicked just first element goes left</li>
  </ul>
  
  <p>my code works but just for one group, not for 2-3-4 groups...</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-js lang-js prettyprint-override"><code>$('.carta:first').click(function() {
    if ($('.isOut').length &lt; $('.carta').length) {
      $('.carta').addClass('isOut');
    } else {
      $(this).removeClass('isOut');
    }
  })
  
  $('.carta:not(:first)').click(function() {
    $(this).toggleClass("isOut");
  })</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>body {
    background: grey;
  }
  
  .carta {
    background: blue;
    width: 50%;
    height: 50px;
    margin-left: 0%;
  }
  
  .isOut {
    margin-left: 30%;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class=gruppo name=team[]&gt;
    &lt;div class="carta"&gt;1 first&lt;/div&gt;&lt;br&gt;
    &lt;div class="carta"&gt;1&lt;/div&gt;&lt;br&gt;
    &lt;div class="carta"&gt;1&lt;/div&gt;
  &lt;/div&gt;&lt;br&gt;
  &lt;hr&gt;
  &lt;br&gt;
  &lt;div class=gruppo name=team[]&gt;
    &lt;div class="carta"&gt;2 first&lt;/div&gt;&lt;br&gt;
    &lt;div class="carta"&gt;2&lt;/div&gt;&lt;br&gt;
    &lt;div class="carta"&gt;2&lt;/div&gt;&lt;br&gt;
    &lt;div class="carta"&gt;2&lt;/div&gt;&lt;br&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>fiddle here: <a href="http://jsfiddle.net/3mejdq4y/" rel="nofollow noreferrer">http://jsfiddle.net/3mejdq4y/</a></p>