title: Remove option from select when selecting them and add the value to a div. When clicking on the div, return the option to the select
body: <p>I have a <code>&lt;select&gt;</code> with some options. When selecting an option, I want it to disappear from the <code>&lt;select&gt;</code> and appear in a div. Then, when the option is in the div, if I click over it, I want it to disappear and return to the select.</p>
  
  <p>I have this code:</p>
  
  <p>jQuery:</p>
  
  <pre><code>$(".car").click(function()
  {
      var $id = $('#selector option:selected').val();
      var $text = $('#selector option:selected').text();
  
      $("#selector option[value='" + $id + "']").remove();
  
      $('.cars').append('&lt;div class="hey" id="' + $id + '"&gt;' + $text + '&lt;/div&gt;');
  
  
      $(".hey").click(function () {
          $(this).remove();
  
          var $value = $(this).attr('id');
          var $text1 = $(this).text();
  
          $('#selector').append('&lt;option class="car" value="' + $value +'"&gt;' + $text1 +'&lt;/option&gt;');
      });
  });
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div id="myDiv"&gt;
      &lt;div class="cars"&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;select id="selector"&gt;
      &lt;option class="car" value="alfaromeo"&gt;Alfa Romeo&lt;/option&gt;
      &lt;option class="car" value="volvo"&gt;Volvo&lt;/option&gt;
      &lt;option class="car" value="ford"&gt;Ford&lt;/option&gt;
      &lt;option class="car" value="opel"&gt;Opel&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p><a href="https://jsfiddle.net/jqvtyt7f/" rel="nofollow">https://jsfiddle.net/jqvtyt7f/</a></p>
  
  <p>But there are some huge problems. If I select more than a car brand at once, when clicking on a brand name, the brand name returns to the list repeated 2, 3 or 4 times (depending on how many brands are selected and its position)
  I also cant reselect an option more than once...</p>
  
  <p>I am a novice with javascript and i have no idea about what is going on. Any help would be highly appreciated.</p>